1

I want to use count/ sum multiple fields in a single query sample data and desired result is as listed below:

MemID  claimNum  ItemID PaidAmt 
123    1234      4      5
123    2309      4      5 
123    1209      4      5 
123    1209      8      2.2
123    1210      8      2.2

Desired result

MemID  count(claimNum) count(ItemID) sum(PaidAmt) 
123    3               3             15 
123    2               2             4.4   
1
  • Why are you counting both claims and items? Also, this is a simple aggregation query, so you should show what you have tried. Commented Apr 21, 2016 at 18:45

2 Answers 2

1

It looks like you want to group by both MemID and ItemID:

select MemID, count(claimNum), count(ItemID), sum(PaidAmt) 
  from the_table 
group by MemID, ItemID
Sign up to request clarification or add additional context in comments.

Comments

0

Use group by ItemID

select MemID, count(claimNum), count(ItemID), sum(PaidAmt) 
from my_table 
group by MemID, ItemID

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.