ANY dialect question:
nested queries
I am using SQL Server 2005 don't which dialect that would be SQL 92 I am guessing !
How can I get:
1) only the Top 2 highest InvoiceTotal rows for each VENDOR in each STATE.
2) the VENDORNAMES that have supplied ONLY the highest number of Invoices for each state.
For the first query, I know this is wrong but what should i be doing??
[sql]
Select top 2 Invoicetotals, vendorname, vendorstate
from vendors join invoices on vendorID
Group by vendorstate, Vendorname
Order by InvoiceTotal DESC
[/sql]
For the second query, I didn't quite get it:
[sql]
Select vendorname, vendorstate, count(*) as InvoiceQty
from vendors join invoices on vendorID
Group by VendorState, VendorName
Order by InvoiceTotal DESC
[/sql]
Help !
|