click below
click below
Normal Size Small Size show me how
SQL questions
| Question | Answer |
|---|---|
| primary key and foreign key | primary should be unique and cannot be null foreign key can have duplicates and can be null |
| core interfaces in JDBC | driver, connection, statement, result set |
| retrieve unique records from table | using select distinct |
| difference between WHERE and HAVING clauses | -having is used when we have multi row function -where is conditions that dont have multi row function |
| difference between GROUP BY and ORDER BY | - GROUP BY: groups data and used with aggregate functions - ORDER BY: ordering data in ascending and descending order |
| how to get first name of employees whose name contains letter'a' | using like |
| difference between INNER, JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN | -INNER JOIN: returns only matching rows - LEFT JOIN: returns all rows from left table and matching rows from right - RIGHT JOIN: returns all rows from the right table and matching in left - FULL JOIN: returns all rows from both sides |
| query to get 2nd largest salary from employees table | select Max(salary) as second_highest_salary from employees where salary<select (max(salary) from employees) |
| difference between DELETE, TRUNCATE and DROP | -DELETE: deletes specific data from table - TRUNCATE: deletes all data from table - DROP: deletes data and table structure |
| query to detect duplicate email addresses in users table | group by and having clause |
| counts grouped by a column | using count() aggregate and group by clause |
| validate api responses against database values | inspect http status code, check response headers and content, verify data accuracy |
| write sql queries in automation framework | using prepared statement and statement |
| subquery | query inside another query |
| unique and aggregate functions | count, sum, ,min, max, avg + |