Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 01, 2013 04:32 PM by gimimex
Member
89 Points
414 Posts
Jan 01, 2013 01:55 PM|LINK
I have a table that has a PlanId field which has the values as below
BP-GEN1 BP-MOT1 BP-HOMESEC GENINS VTPLAN
Just want to get the count of PlanId's that has '-' charector in it (BP-GEN1,BP-MOT1 etc).
I tried this way..not sure whether this is the right way. not working..
select count(PlanID) as 'PlanID', CHARINDEX('-', PlanID) from InsDetails where DisId ="INGEN" group by PlanID having count(CHARINDEX('-', PlanID) > 0
Please help me out
Participant
1052 Points
157 Posts
Jan 01, 2013 04:32 PM|LINK
Try:
select count(PlanID) as 'PlanID' from InsDetails where DisId = 'INGEN' and CHARINDEX('-', PlanID) > 0
Hope this helps.
Chithra_Iyer
Member
89 Points
414 Posts
Get row count based on CHARINDEX
Jan 01, 2013 01:55 PM|LINK
I have a table that has a PlanId field which has the values as below
BP-GEN1
BP-MOT1
BP-HOMESEC
GENINS
VTPLAN
Just want to get the count of PlanId's that has '-' charector in it (BP-GEN1,BP-MOT1 etc).
I tried this way..not sure whether this is the right way. not working..
select count(PlanID) as 'PlanID', CHARINDEX('-', PlanID) from InsDetails where DisId ="INGEN"
group by PlanID having count(CHARINDEX('-', PlanID) > 0
Please help me out
gimimex
Participant
1052 Points
157 Posts
Re: Get row count based on CHARINDEX
Jan 01, 2013 04:32 PM|LINK
Try:
select count(PlanID) as 'PlanID' from InsDetails where DisId = 'INGEN' and CHARINDEX('-', PlanID) > 0Hope this helps.