View previous topic :: View next topic
|
Author |
Message |
sanjay sahu
New User
Joined: 18 Feb 2014 Posts: 3 Location: India
|
|
|
|
Please help me to find the suitable query to extract the result
I have a payment table like below:-
Code: |
Customer-Id BillCompany Payment
-------------- ------------- -----------
111111 Reliance 100
222222 Airtel 200
333333 M&S 50
444444 Digits 5000
111111 Airtel 20
444444 Reliance 50
333333 Airtel 2000
111111 Reliance 100
111111 Reliance 100
222222 Airtel 200
444444 Digits 333
111111 Idea 898
222222 Vodafone 253
111111 BSNL 10 |
I want to list the Customer-id and the number of Billcompany assigned to customer.
My output should be like:-
As Customer 111111 has total 4 bill company added(Reliance, Airtel, Idea, BSNL), Customer 222222 has total 2 bill comapny added(Airtel, Vodafone)...
Code: |
Customer-Id Total no of Bill company
111111 4
222222 2
333333 2
444444 2 |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
First, when posting info that needs to retain alignment, you should use the Code tag.
What have you tried and what happened?
We expect members to try to code their query and show what happens if it is not what was needed.
There are many exanples here in the DB2 part of the forum. Which is where this should have been posted. . . I'll relocate the topic for you. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
Code: |
...
count(distinct billcompany)
... |
|
|
Back to top |
|
|
|