Page 48 - Modular_V2.0_SQL_Flipbook
P. 48

C.  Fill in the blanks using the words given below:



                                                   Date, Having, Where , Order By, Sum()

                 1.  The …………………… keyword sorts the data in a table in ascending or descending order.

                 2.  The GROUP BY also comes with …………………… clause.

                 3.  The …………………… clause is same as "Having" clause in MySQL.
                 4.  …………………… function finds the sum of values under a specific column.

                 5.  Date functions operate on values of the …………………… data type.

              D.  Short answer type questions.
                 1.  What is the use of Group By command?
                 2.  Write the MySQL code for the following query. Consider the table name as products.
                   Display the name, price of a product whose code is P06.
                 3.  What are aggregate functions in MySQL?

                 4.  What is a function in MySQL?
                 5.  What is the purpose of NOW() function?

              E.  Long answer type questions.
                 1.  Consider the following table:

                    Table: ACCOUNT
                                        A_no                  A_name                  Address
                                         101           Nirja Singh             Bangalore
                                         102           Rohan Gupta             Chennai
                                         103           Ali Reza                Hyderabad
                                         104           Rishabh Jain            Chennai
                                         105           Simran Kaur             Chandigarh

                   Table: TRANSACTION
                               Tr_no            A_no          Amount            Type             DOT
                               T010             101            25000       Withdrawal        2022-12-21
                               T011             103            30000       Deposit           2022-06-01
                               T012             102            20000       Withdrawal        2022-05-12
                               T013             103            10000       Deposit           2022-10-22
                               T014             102            120000      Deposit           2022-01-06

                   Write the query:

                     i.  To display details of all transactions of TYPE Deposit from TRANSACTION  table
                    ii.   To display A_no, Type and Amount of all Deposit and Withdrawals done in month of  January 2022
                        from table TRANSACTION
                    iii.  To display first date of transaction (DOT) from table TRANSACTION for Account having A_no as 105
                    iv.   To display A_no, A_name, Amount and DOT of those persons from ACCOUNT and TRANSACTION
                        table who have done transaction less than 25000


                46
                      Touchpad MODULAR (Ver. 2.0)
   43   44   45   46   47   48   49   50   51   52   53