May 6, 2009 at 8:33 am
I trying to determine which clients have more than one default currency from a table of sales data. It seems like a simple query but for some reason I can't wrap my head around it. any help would be greatly appreciate it
May 6, 2009 at 8:54 am
We want to see you do some work, so make an attempt.
As a hint, group by the clients, count the currencies.
And you'll need a HAVING clause.
May 6, 2009 at 9:19 am
thanks for the advice, i'll give it a go
May 6, 2009 at 9:23 am
it gives me the number of transactions for each currency not the customers that have two different currencies
0000104691USD41
0000104698USD450
0000104707USD4
0000104708USD266
0000104710USD35
0000104717CAD440
0000104724CAD3
I need to know if 0000104724 has orders in CAD and in USD or EUR as an example
thanks
May 6, 2009 at 9:25 am
Show some code here, and we'll help you out. Seeing results doesn't help me figure out what you're doing wrong.
May 6, 2009 at 12:09 pm
select distinct custno, currency, COUNT(currency) from tblSales
group by custno, currency having currency = 'USD' or currency='CAD'
order by custno
May 7, 2009 at 3:08 am
klanguedoc (5/6/2009)
select distinct custno, currency, COUNT(currency) from tblSalesgroup by custno, currency having currency = 'USD' or currency='CAD'
order by custno
Hi,
from your codeing result for count of currency alwayes one,
--only the customer having more than one currency
select custno,COUNT(currency) from tblSales
where currency in('USD','CAD')
group by custno
having COUNT(currency)>1
--for all the records
select custno,COUNT(currency) from tblSales
where currency in('USD','CAD')
group by custno
ARUN SAS
May 7, 2009 at 6:24 am
Thanks Old Hand...this is fabulous
kevin
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply