Page 301 - IT-802_class_12
P. 301

10.   Satyam is using a table EMPLOYEE with the fields – CODE, NAME, SALARY, DEPT_CODE. He wants to display maximum
                 salary Department-wise. Write appropriate MySQL command to do so.
                            +-----------+-------------+------+-----+---------+-------+
                            | Field     | Type        | Null | Key | Default | Extra |
                            +-----------+-------------+------+-----+---------+-------+
                            | CODE      | int         | yES  |     | NULL    |       |
                            | NAmE      | varchar(40) | yES  |     | NULL    |       |
                            | SALARy    | int         | yES  |     | NULL    |       |
                            | DEpT_CODE | int         | yES  |     | NULL    |       |
                            +-----------+-------------+------+-----+---------+-------+

             Ans. SELECT DEpT_CODE, mAX(Salary) FROm Employee GROUp By DEpT_CODE;
              11.  A table FOOD has 13 rows and 17 columns. What is the cardinality and degree of the table?
             Ans. Cardinality = 13

                 Degree = 17
              12.  Consider the table of Ques 10, Write a query to display the name of all employees in alphabetical order.

             Ans. SELECT Name FROm EmpLOyEE ORDER By Name ASC;
              13.   James created a table CLIENT with 2 rows and 4 columns. What is the Cardinality and Degree of the Table. He modified
                 the table and added 2 more rows to it and deleted one column. What is the Cardinality and Degree of the table now?
             Ans. Before modification:

                 Cardinality = 2
                 Degree = 4
                 After modification:

                 Cardinality = 4
                 Degree = 3

              14.   Consider the table EXAM with the fields – ADM_NO, SNAME, PERCENTAGE, CLASS, STREAM. Write a query to display
                 the names of all students in decreasing order of percentage (high to low)

                            +------------+-------------+------+-----+---------+-------+
                            | Field      | Type        | Null | Key | Default | Extra |
                            +------------+-------------+------+-----+---------+-------+
                            | ADm_NO     | int         | yES  |     | NULL    |       |
                            | SNAmE      | varchar(40) | yES  |     | NULL    |       |
                            | pERCENTAGE | double      | yES  |     | NULL    |       |
                            | CLASS      | char(3)     | yES  |     | NULL    |       |
                            | STREAm     | varchar(20) | yES  |     | NULL    |       |
                            +------------+-------------+------+-----+---------+-------+

             Ans. SELECT SNAmE FROm EXAm ORDER By pERCENTAGE DESC;
              15.   Consider the table of Ques 14, write a query to display the names of all students who have scored more than 80
                 percent.

             Ans. select SNAmE from exam where pERCENTAGE > 80;
              16.  Consider the table of ques 14, modify the table and add a column BUS_FEE having data type and size as Decimal(4).

             Ans. ALTER TABLE EXAm ADD BUS_FEE Decimal(4);






                                                                                                Practical Work  299
   296   297   298   299   300   301   302   303   304   305   306