Database Reference
In-Depth Information
Figure 6.28
Use DISTINCT and ORDER BY.
Figure 6.29
Use TOP.
To combine the outputs from two diferent queries, you can use the UNION keyword. To
see how UNION works, consider the example in Figure 6.30. In this example, UNION is used
to combine the faculty member with the id 1 and the students advised by this faculty member.
he PIVOT keyword can be used to categorize a set of records returned from a SELECT state-
ment in a cross-classiication table. For example, to ind out how many As, Bs, Cs, Ds, and Fs are
earned by each student, you can run the SQL statement displayed in Figure 6.31.
Figure 6.30
Use UNION.
Search WWH ::




Custom Search