The different types of JOINs:
See Jeff Atwood's Visual Explanation of JOINs
What is an index and how does it help your database?
What are the data types available and when to use which ones?
A reprint of my answer here, as general guidelines for topics.
SELECT
ing columns from a tableCOUNT
, SUM
, MAX
/MIN
DISTINCT
, GROUP BY
, HAVING
JOIN
s, ANSI-89 and ANSI-92 syntaxUNION
vs UNION ALL
NULL
handling: COALESCE
& Native NULL handlingIN
, EXISTS
, and inline viewsWITH
syntax: Subquery Factoring/CTECOMMIT
, ROLLBACK
, Error HandlingHere are a few:
What is sql injection and how do you prevent it?
What is a cursor and when would you use it (or not) and why?
I've placed this answer because Erwin Smout posted a answer that was so wrong it highlighted that there is probably a need to specifically guard against it.
Erwin suggested:
"Why should every SELECT always include DISTINCT ?"
A more appropriate question would be: If someone were to make the claim that: "every SELECT always include DISTINCT"; how would you comment on the claim?
If a candidate is unable to shoot the claim down in flames they either:
For the record
At our company, instead of asking a lot of SQL questions that anyone with a good memory can answer, we created a SQL Developers test. The test is designed to have the candidate put together a solid schema with normalization and RI considerations, check constraints etc. And then be able to create some queries to produce results sets we're looking for. They create all this against a brief design specification we give them. They are allowed to do this at home, and take as much time as they need (within reason).
I would give a badly written query and ask them how they would go about performance tuning it.
I would ask about set theory. If you don't understand operating in sets, you can't effectively query a relational database.
I would give them some cursor examples and ask how they would rewrite them to make them set-based.
If the job involved imports and exports I would ask questions about SSIS (or other tools involved in doing this used by other datbases). If it involved writing reports, I would want to know that they understand aggregates and grouping (As well as Crystal Reports or SSRS or whatever ereporting tool you use).
I would ask the difference in results between these three queries:
select a.field1
, a.field2
, b.field3
from table1 a
join table2 b
on a.id = b.id
where a.field5 = 'test'
and b.field3 = 1
select a.field1
, a.field2
, b.field3
from table1 a
left join table2 b
on a.id = b.id
where a.field5 = 'test'
and b.field3 = 1
select a.field1
, a.field2
, b.field3
from table1 a
left join table2 b
on a.id = b.id and b.field3 = 1
where a.field5 = 'test'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With