PostgreSQL is a powerful open-source database known for its rich set of functions and aggregates. This guide features 30 essential MCQs to enhance understanding of PostgreSQL’s core functionalities and data manipulation techniques.
DISTINCTWHERE NOT NULLCOUNTNULLS()COUNT(*)COUNT(DISTINCT column_name)DISTINCT COUNT(column_name)COUNT(column_name DISTINCT)YEAR(date_column)EXTRACT(YEAR FROM date_column)GET_YEAR(date_column)TO_YEAR(date_column)| Qno | Answer (Option with text) |
|---|---|
| 1 | a) COUNT() |
| 2 | b) Adds values in a numeric column |
| 3 | a) AVG() |
| 4 | c) By default, aggregate functions exclude NULLs |
| 5 | b) SELECT |
| 6 | b) COUNT(DISTINCT column_name) |
| 7 | a) MAX() |
| 8 | b) UPPER() |
| 9 | a) LENGTH() |
| 10 | a) Joins two or more strings |
| 11 | a) SUBSTR() |
| 12 | a) Finds the position of a substring within a string |
| 13 | c) REPLACE() |
| 14 | a) TRIM() |
| 15 | b) CURRENT_DATE |
| 16 | a) Calculates the difference between two timestamps |
| 17 | b) EXTRACT(YEAR FROM date_column) |
| 18 | b) TO_TIMESTAMP() |
| 19 | a) Defines a time period |
| 20 | c) NOW() + INTERVAL |
| 21 | c) EXTRACT(DOW FROM date_column) |
| 22 | b) GROUP BY |
| 23 | a) HAVING filters grouped data |
| 24 | a) SUM() in combination with GROUP BY |
| 25 | c) COUNT(DISTINCT column_name) |
| 26 | a) Generates subtotals and grand totals |
| 27 | a) Use HAVING |
| 28 | a) GROUP BY and ORDER BY |
| 29 | d) No default order |
| 30 | a) To define multiple grouping levels |