mehfuz.khaled (7/20/2013)
Hello all, I am not sure whether this is the right thread to post this or not.Anyways, I have one table as follows:
table mastertab(
op INT,
msisdn VARCHAR (12),
imei VARCHAR (20)
);
Sample values that I have are as follows:
aa, 0191, 111222333
aa, 0191, 111222444
aa, 0192, 111222333
aa, 0192, 111222444
aa, 0192, 111222555
aa, 0193, 111222333
bb, 0171, 222222333
bb, 0171, 222222444
bb, 0172, 222222444
cc, 0152, 333222444
Now, i want the output to show as (op, imei_count) set where imei_count displays the total number of duplicate imei and groups it by op. Expected output is as follows:
op imei_count
-- ----------
aa 2
bb 1
cc 0
Any help in this regard will highly be appreciated.
Thanks,
Mehfuz
First, you're new here. You'll get a whole lot more coded, tested answers if you follow the simple advice offered in the first link in my signature line below.
Second, what do you want to be returned if the data is like this?
aa, 0191, 111222333
aa, 0191, 111222444
aa, 0192, 111222333
aa, 0192, 111222444
aa, 0193, 111222555
aa, 0194, 111222555
aa, 0195, 111222556
aa, 0196, 111222556
--Jeff Moden
Change is inevitable... Change for the better is not.