![]() SELECT t.customer_id, MIN(t.transaction_date) AS first_transaction_date, MAX(t.transaction_date) AS last_transaction_date, MAX(t.transaction_amount) – MIN(t.transaction_amount) AS diff_amount, MAX(t.transaction_date) – MIN(t.transaction_date) AS diff_date FROM transaction t GROUP BY t. SELECT p.product_id, p.product_name FROM products p LEFT OUTER JOIN transaction t ON p.product_id = t.product_id WHERE t.transaction_id IS NULL 4. ![]() SELECT p.product_id, p.product_name, total_amount FROM products p JOIN ( SELECT product_id, SUM(transaction_amount) AS total_amount FROM transaction GROUP BY product_id ORDER BY total_amount DESC ) t ON p.product_id = t.product_id WHERE ROWNUM = 1 3. SELECT * FROM ( SELECT transaction_id, customer_id, transaction_date, product_id, transaction_amount, ROW_NUMBER() OVER (ORDER BY transaction_date DESC) AS rn FROM transaction WHERE customer_id = 1 –(let 1) and transaction_date >= TRUNC(SYSDATE, ‘MM’) – 30 ) WHERE rn <= 10 order by transaction_id,customer_id 2. Or, you can also jump to our below two sections on SQL interview questions for freshers and experienced professionals.ġ. Write a query to find the 3rd highest salary from a table without top or limit keyword.Write an SQL query to fetch only odd rows from the table.Write an SQL query to fetch duplicate records from EmployeeDetails.Write an SQL query to fetch all the Employees who are also managers.Fetch employee names and salaries even if the salary value is not present for the employee.Write an SQL query to fetch a project-wise count of employees.Fetch all employees from EmployeeDetails who have a salary record in EmployeeSalary.SQL query to fetch all the Employees from EmployeeDetails who joined in the Year 2020.SQL query to fetch all the employees who are not working on any project.SQL Query to fetch records that are present in one table but not in another table.You can try solving these questions and click on the links to go to their respective answers. The basic syntax of an SQL statement consists of a command followed by a clause and conditions. It includes the use of keywords, clauses, operators, and functions that are used to query and manipulate data in a relational database. If you want to skip the basic questions and start with some tricky SQL queries then you can directly move to our SQL queries interview questions for the experienced section.Ĭonsider the below two tables for reference while trying to solve the SQL queries for practice.įor your convenience, I have compiled the top 10 questions for you. SQL syntax refers to the rules and guidelines that define how to correctly write SQL statements. ![]() In fact, I have been asked most of these questions during interviews in the different phases of my career. Whether you are a DBA, developer, tester, or data analyst, these SQL query interview questions and answers are going to help you. Hello friends! in this post, we will see some of the most common SQL queries asked in interviews. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |