Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
vipinjha
Starting Member
21 Posts |
Posted - 2012-03-22 : 06:28:06
|
Dear All,I am posting my query in which i want to have only those record which is having same mobile number more than 3 timesneed to use group by and havingplease tell me proper syntax for same.SELECT case when len(PHONENO) > 4 then '******' + RIGHT(PHONENO, 4) else PHONENO end "Cell Number",PHONENO "CellNumber", GAM.FORACID Account_Number,GAM.SCHM_CODE,CMG.PAN_GIR_NUM "Pan Number",CMG.CIF_IDFROM DWH_STAGING..PHONEEMAIL left join DWH_STAGING..CMG(NOLOCK) on CMG.CUST_ID= PHONEEMAIL.ORGKEYleft join DWH_STAGING..GAM(NOLOCK) on GAM.CIF_ID=CMG.CIF_IDwhere PHONENO<>'0' and PHONENO is not null AND PHONEEMAIL.PHONENO LIKE '%9833774765%'and phoneoremail = 'PHONE' and preferredflag = 'Y'Thankx & regards,Vipin jhaVipin jha |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-03-22 : 07:00:40
|
You have two columns that look like cell number. "Cell Number" and "CellNumber". Are you looking for those two columns having the same value, or is it three different rows where one of those columns are the same, or two or more rows where at least one of those is repeated - or something else?Can you post some sample data and expected output that would cover these cases? |
 |
|
vipinjha
Starting Member
21 Posts |
Posted - 2012-03-22 : 07:21:56
|
bothe coumn are same ,diffrnce is that i dont want to show user mobile number number, pupose of this report is that suppose one mobile number is assigning to 10 user .so if i put the mobile number it will show the same number having more than 3 user detailsCellNumber Account_Number9833774765 NULL9833774765 NULL9833774765 NULL9833774765 NULL9833774765 NULL+000(000)9833774765 6.73209E+129833774765 NULL9833774765 NULL9833774765 NULL9833774765 NULL9833774765 NULL9833774765 9.61012E+129833774765 NULL9833774765 NULLVipin jha |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-22 : 15:42:32
|
you want values like +000(000)9833774765 to be considered similar to 9833774765 ?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|