thenoisydrum
Registered User.
- Local time
- Today, 21:20
- Joined
- Jul 26, 2012
- Messages
- 52
Hi,
I have spent a long time trying to find a solution to this but I'm struggling....
I'm not sure whether it is the distinct function that I need but I am hoping that somebody here can help.
My dataset is invoices. Specifically, invoices for Belgian customers. Some of these invoices are for transactions in Belgium (domestic) and some of them are in other countries (non-domestic).
I need to select 2 random invoices from each of the non-domestic countries.
How do I do that?
Originally I was tasked with selecting 5 random non-domestic invoices so used;
SELECT TOP 5 *
FROM [my table]
WHERE [Transaction Country] <> 'BELGIUM'
ORDER BY Rnd([Invoice Number]);
This worked a treat but now that I need to modify it to be 2 random invoices for each of the domestic countries I am stuck.
Can anybody help?
Thanks in advance
I have spent a long time trying to find a solution to this but I'm struggling....
I'm not sure whether it is the distinct function that I need but I am hoping that somebody here can help.
My dataset is invoices. Specifically, invoices for Belgian customers. Some of these invoices are for transactions in Belgium (domestic) and some of them are in other countries (non-domestic).
I need to select 2 random invoices from each of the non-domestic countries.
How do I do that?
Originally I was tasked with selecting 5 random non-domestic invoices so used;
SELECT TOP 5 *
FROM [my table]
WHERE [Transaction Country] <> 'BELGIUM'
ORDER BY Rnd([Invoice Number]);
This worked a treat but now that I need to modify it to be 2 random invoices for each of the domestic countries I am stuck.
Can anybody help?
Thanks in advance