SQL Assessment
SQL Assessment
SELECT name
What will FROM
be the customer
result WHERE
of the query state = 'VA';
below?
select case when null = null then 'Y' else 'N' end as Result;
Which one of the following statement is true to show the 2 highest salary from Employee table?
Option A
select id from table order by id desc limit 1
Select * from table where id % 2 != 0
100
90
30
9000
Answer:
order_date_time.
Question
Write an SQL query to find out how many users toouched more than 1000 but less than 2000 or
Table event_log
user_id order_date_time
7494212 1535308430
7494212 1535308433
1475185 1535308444
6946725 1535308475
6946725 1535308476
6946725 1535308477
… …
Answer:
but less than 2000 orders
Question Write a query that every department where the average salary per employee is lower th
Answer:
per employee is lower than 500?
Salaries
employee_idemployee_name
123 John Doe
211 Jane Smith
556 Billy Bob
711 Robert Hayek
235 Edward Jorgson
236 Christine Packard
… …
Question SELECT name FROM Customers WHERE referredby <> 2;
Table Customers
id name referredby
1 John NULL
2 Jane NULL
3 Anne 2
4 Eric NULL
5 Pat 1
6 Alice 2
Answer:
Write a SQL query to return a list of all the invoices?
Question
Answer:
Customers
data_type allow_nulls
int no
varchar no
int Yes
Question
Write a query to find duplicate records with one filed name?
Table Users
name email
John John@
Jane Jane@
Alice Alice@
Lisa Lisa@
Answer:
Question Write a Query from below input table to get the output table results?
Answer:
ults?
Answer:
ults?
decimal
12
34
67
48
48
Write a single query to calculate the sum of all positive values of profit column and the s
Question
below table?.
Table Sales
profit
10000
5800
-5200
-48000
65000
35000
-12004
4500
-1000
Answer:
f profit column and the sum of all negative values of profit column from the
Question SELECT * FROM Runners WHERE id NOT IN (SELECT winner_id FROM Races)
id name id event
1 John 1 100 Meter
2 Jane 2 500 Meter
3 Alice 3 200 Meter
4 Bobby 4 1000 Meter
5 Lisa
Answer:
ROM Races)
winner_id
2
3
2
NULL