Page 230 - Informatics_Practices_Fliipbook_Class12
P. 230
Ans. i. ORDER BY clause in SQL is used to sort the result set of a query based on one or more columns.
ii. The HAVING clause is used in SQL queries to filter the results of a GROUP BY clause based on a specified condition.
c. Site any two differences between Single_row functions and Aggregate functions.
Ans. i. Single row functions operate on a single row from the table at a time whereas aggregate functions operate on a set of
rows at a time.
ii. Single row function display output for single row and display number rows whereas aggregate functions display out as
a single value from a set of rows.
d. What do you understand by Cartesian Product?
Ans. In a relational database management system (RDBMS), the Cartesian Product is a mathematical operation that combines
every row from one table with every row from another table. The result is a new table where each row represents a
combination of rows from the original tables. The size of the Cartesian Product is the product of the number of row sin each
table. It is denoted by the symbol "×" or by using the CROSS JOIN operation in SQL.
e. Write the name of the functions to perform the following operations:
i. To display the day like “Monday”, “Tuesday”, from the date when India got independence.
ii. To display the specified number of characters from a particular position of the given string.
iii. To display the name of the month in which you were born.
iv. To display your name in capital letters.
Ans. i. SELECT DAYNAME('1947/08/15');
+-----------------------+
| DAYNAME('1947/08/15') |
+-----------------------+
| Friday |
+-----------------------+
ii. SELECT SUBSTRING('Hello, World!', 1, 5) AS result;
+--------+
| result |
+--------+
| Hello |
+--------+
iii. SELECT MONTHNAME('2019-09-24') AS birth_month;
+-------------+
| birth_month |
+-------------+
| September |
+-------------+
iv. SELECT UPPER('ankit') as nameUpperCase;
+---------------+
| nameUpperCase |
+---------------+
| ANKIT |
2. Write the output produced by the following SQL commands:
a. SELECT POW(2,3);
b. SELECT ROUND(123.2345, 2), ROUND(342.9234,-1);
c. SELECT LENGTH("Informatics Practices");
d. SELECT YEAR("1979/11/26"), MONTH("1979/11/26"), DAY("1979/11/26"), MONTHNAME ("1979/11/26");
e. SELECT LEFT("INDIA",3), RIGHT("Computer Science",4);
f. SELECT MID("Informatics",3,4),SUBSTR("Practices",3);
216 Touchpad Informatics Practices-XII

