TSQL Select Third Largest Value
Hi Everyone,
I didn't know we have SQL forum on VBAX so I just posted this thread in another forum too.
I am totally a Newbie to T-SQL and need to pass a technical test for my interview. I have done the most of them but stuck with this one below:
Question: Select account name, contact last name, case number, quote number, quote date and quote value for the third largest quote ever created for each of the accounts in the BR2 area.
There are 4 tables: account, contact, case, quote
the query I wrote:
Code:
SELECT ac.AccountName, cn.LastName, cs.CaseNumber, q.QuoteNumber, q.QuoteDate, q.Value
FROM Tbl_Account ac LEFT JOIN Tbl_Contact cn
ON ac.AccountID=cn.AccountID
JOIN Tbl_Case cs
ON cn.ContactID=cs.ContactID
JOIN Tbl_Quote q
ON cs.CaseID=q.CaseID
WHERE ac.Postcode LIKE 'BR2%';
I don't know how to select third largest quote ever created for each of the accounts in BR2 area. Can anyone help me with this please?
Cheers
B.