Professional Documents
Culture Documents
SQL Test1
SQL Test1
SQL Test1
Synergise.
2. List and explain the different types of JOIN clauses supported in ANSI-standard
SQL.
Solve.
Synergise.
12.
13.
14.
15.
16.
17.
18.
19. |
4 | triathalon
NULL
Solve.
Synergise.
4. What will be the result of the query below? Explain your answer and provide a
version that behaves correctly.
select case when null = null then 'Yup' else 'Nope' end as
Result;
Solve.
Synergise.
100
+-------+
sql> select Count(*) as Cust123Total from Orders where
customer_id = '123'
+--------------+
| Cust123Total |
+--------------+
|
15
+--------------+
Given the above query results, what will be the result of the query below?
sql> select Count(*) from Orders where customer_id <> '123'
Solve.
Synergise.
6. Given a table, such as the one below, that has m = male and f =
female values. Swap all f and m values (i.e., change all f values to m and
vice versa) with a single update query and no intermediate temp table.
Id
Name Sex
Salary
2500
1500
5500
500
Solve.
Synergise.
Solve.
Synergise.
Solve.
Synergise.
******************************************
10. Considering the database schema displayed in the SQLServer-style diagram
below, write a SQL query to return a list of all the invoices. For each invoice,
show the Invoice ID, the billing date, the customers name, and the name of the
customer who referred that customer (if any). The list should be ordered by billing
date.
Solve.
Synergise.
************************************
11. Given these contents of the Customers table:
Id
Name
ReferredBy
John Doe
NULL
Jane Smith
NULL
Anne Jenkins
Eric Branford
Pat Richards
Alice Barnes
NULL
Here is a query written to return the list of customers not referred by Jane Smith:
SELECT Name FROM Customers WHERE ReferredBy <> 2;
What will be the result of the query? Why? What would be a better way to write it?
Solve.
Synergise.
12.