|
-
Feb 2nd, 2010, 05:17 AM
#1
Thread Starter
Hyperactive Member
Select unique records with JOIN
Hi
I'm trying to select some rows but keep getting double the number of records because of duplicates for each record in table calltypes. Here's what I have:
SELECT DISTINCT TA.GroupName, SUM(TB.Customer_Call_Cost), COUNT(TB.ID)
FROM CallTypes AS TA INNER JOIN VoiceTable AS TB ON TA.GroupName=TB.Customer_Call_Group
WHERE TB.Customer_Index=1 And TB.Date_Time_Called>=#5/1/2009# And TB.Date_Time_Called<=#5/31/2009 23:59:59#
GROUP BY TA.GroupName
ORDER BY TA.GroupName;
It returns this:
GroupName Expr1001 Expr1002
International 76.89 140
Mobile 33.32 252
National 3.51 64
Other 0.15 8
When it should return this:
GroupName Expr1001 Expr1002
International 76.89 70
Mobile 33.32 126
National 3.51 32
Other 0.15 4
I'd be grateful for help. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|