Reputation: 99
i have a table with two columns SERVICE and ANI. let's say like the one below
SERVICE ANI _________________ CRIC 54321 MOVIES 87945 FITNESS 64587 MUSIC 54321 CRIC 54321 FITNESS 87945 FITNESS 87945 MUSIC 87945 MOVIES 54321 MUSIC 64587 CRIC 64587 FITNES 54321
(ANI is Phone number) and I have find out to that how many times a single ANI calls for a particular service. i have to group by ANI and service and find out the count of each ANI for each SERVICE. output should be something like
(SERVICE) (ANI) (ANI_COUNT) CRIC 54321 2 MUSIC 54321 1 MOVIES 87945 1 FITNESS 87945 2
and so on. it means that the ANI 54321 has called twice for CRIC service and once for music. ANI 87945 has called once for MOVIES and twice for FITNESS
can anybody guide me how can i do it?
Upvotes: 1
Views: 119
Reputation: 89315
If I understand the question correctly, you can try to group by SERVICE
and ANI
as follow, to achieve output like the 2nd code block in this question :
SELECT
SERVICE, ANI, COUNT(*) AS 'ANI_COUNT'
FROM
MyTable
GROUP BY SERVICE, ANI
Upvotes: 1