B.6. MORE SUBQUERY EXAMPLES—SALES REPS AND QUOTAS

For this example, consider these tables:

Reps(SRName, SRid, OffCity, Quota )-- Reps contains sales reps
Sales( RepSSAN, Custid, Amount)-- Sales custs and amounts for each rep
Offices(OffName, Target)-- Sales offices and their sales ta gets

Consider this sample data:

SQL
									SELECT * FROM Reps;
								
 
Result
SRName            SRid                  OffCity            Quota------------      ----------            ---------          -------Amy               111                   San Jose           30Sue               333                   San Jose           50Zeb               555                   San Jose           70Bob               777                   Boston             50Bab               888                   Boston             55 ...

Get Transact-SQL Desk Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.