
Find answers to commonly asked SQL interview questions.
Joined July 2023
- Tweets34
- Following162
- Followers14
- Likes3
How can you find the 3rd highest salary in Oracle using an analytic function?
#DenseRank #SQL #TutorSQL #Oracle #Analytics #Database #DataAnalyst #DataScientist
15
Q9: Write an SQL query using CASE to calculate the grade for each student:
If the avg of math and science scores is greater than or equal to 90, assign A grade.
If the avg is between 80 & 89, assign B grade
If the avg is between 70 & 79, assign C grade
Otherwise, assign 'D'.
1
45
Q8: Write an SQL query to calculate the month-over-month percentage growth for each product's sales. You should retrieve the product_id, sale_date, and percentage growth from the previous month's sales using the LEAD and LAG functions.
1
37
Protip: 😎 Do you know that using the LEAD and LAG functions effectively and considering both the PARTITION BY and ORDER BY clauses, you can perform robust time-based and comparative analysis on your data in Oracle SQL. 🚀
Q7: In Oracle SQL, the LIMIT function is unavailable, but there's an equivalent approach using the ROWNUM technique. Consider a table named "products" as per the screenshot.
Write an SQL query to retrieve the top 3 cheapest products using the ROWNUM technique (equi. to LIMIT).
1
47
Question #6: Imagine you have a table named "events" with the attached structure and data:
Write an SQL query to extract the hours, minutes, and seconds from the "event_date" column and display them in separate columns in the result set.
Hint: Use the TO_CHAR function.
1
33
Question 5:
write an SQL query to find the total number of orders placed by each customer and display the results in descending order based on the number of orders. If two or more customers have the same number of orders, sort them in ascending order based on their customer_id.
1
24
Question 4:
You have a table named "employees" and data as given in the attachment.
Write an SQL query to extract the first 2 char from "first_name" and the last 3 char from "last_name" for each employee.
1
31
Question: Imagine you have a table named "sales" with the following structure and data:
order_id order_date
1 2023-07-15 08:30:00
2 2023-06-20 13:45:00
Write an SQL query that extracts the year, month, and day from the "order_date".
1
28
Example of a SQL query that can determine the second highest salary from a salary table.
Let's say the salary table looks like this:
amount
50000
60000
45000
75000
55000
The query will result in the second-highest salary, which is 60000. #SQLMastery #DataAnalysis #LearnSQL
21
💻 Say goodbye to complex subqueries and hello to efficiency! 🚀 Here's a quick example: Calculate the average salary within each department using 'salary' column, PARTITIONED BY 'department,' #SQLMastery #DataAnalysis #OVERPARTITION #LearnSQL #TutorSql
23











