Which of the following is a valid correlated subquery for finding employees earning more than their department average?
ASELECT * FROM emp e WHERE salary > (SELECT AVG(salary) FROM emp)
BSELECT * FROM emp e WHERE salary > (SELECT AVG(salary) FROM emp e2 WHERE e2.dept_id = e.dept_id)
CSELECT * FROM emp WHERE salary > ALL (SELECT AVG(salary) FROM emp GROUP BY dept_id)
DBoth B and C
Correct Answer:
D. Both B and C
Explanation:
Both B and C are valid. B is a correlated subquery (references outer query). C uses ALL operator with aggregated subquery. A is incorrect as it compares to global average.
In a bank database with accounts table, which query correctly identifies dormant accounts (no transactions in 2 years)?
ASELECT * FROM accounts WHERE last_transaction_date > DATE_SUB(NOW(), INTERVAL 2 YEAR)
BSELECT * FROM accounts WHERE last_transaction_date < DATE_SUB(NOW(), INTERVAL 2 YEAR)
CSELECT * FROM accounts WHERE last_transaction_date = DATE_SUB(NOW(), INTERVAL 2 YEAR)
DSELECT * FROM accounts WHERE DATEDIFF(NOW(), last_transaction_date) = 730
Correct Answer:
B. SELECT * FROM accounts WHERE last_transaction_date < DATE_SUB(NOW(), INTERVAL 2 YEAR)
Explanation:
Dormant accounts have last_transaction_date LESS THAN 2 years ago (older). Option A finds active accounts. Option D is too strict with exact day matching.
Which anomaly in unnormalized database allows insertion of duplicate partial information without main entity?
AUpdate anomaly
BInsertion anomaly
CDeletion anomaly
DReferential anomaly
Correct Answer:
B. Insertion anomaly
Explanation:
Insertion anomaly occurs when you cannot insert data without complete information. Update anomaly = data inconsistency on updates. Deletion anomaly = loss of data when deleting.
For a multi-million row analytics database, which data type is most storage-efficient for storing yes/no values?
AVARCHAR(5)
BCHAR(1)
CBOOLEAN/BIT
DINT
Correct Answer:
C. BOOLEAN/BIT
Explanation:
BOOLEAN/BIT uses minimal storage (1 byte or bit). CHAR(1) uses 1 byte. VARCHAR(5) uses more. INT uses 4 bytes. For large datasets, storage matters significantly.
iGET uses cookies for essential site functionality, analytics, and ads personalization (via Google AdSense). By clicking "Accept", you consent to our use of cookies.
Privacy Policy ·
Disclaimer