April 28, 2011 at 12:25 pm
iam having table like below
VIDCompnayidDataitemidValuePEO
747298211712163402203
429784349211712163402203
429807485211712163402203
440129783211712163402203
450206461211712163402203
454391415211712163402203
747298211712163602203
429784349211712163602203
429807485211712163602203
440129783211712163602203
450206461211712163602203
454391415211712163602203
by using abiove table i need results like below(count of verions) can any one help me on this
Compnayid DataitemidPEOCount of vid
211712163622036
211712163422036
i am using SQL server 2003 so can i get a code for it
April 28, 2011 at 12:35 pm
use group by clause.
http://msdn.microsoft.com/en-us/library/ms177673(v=SQL.90).aspx
select Compnayid,Count( vid) from tablename
group by companyID
April 28, 2011 at 12:40 pm
i used same earlier but it is displaying like below instaed of 6 iam getting one
216342117122031
216362117122031
select dataitemid,companyId,estimateperiodid, count(prasad)from #prasad_tbl
group by companyId,dataitemid,estimateperiodid,prasad
April 28, 2011 at 12:55 pm
yadagiriprasad (4/28/2011)
i used same earlier but it is displaying like below instaed of 6 iam getting one216342117122031
216362117122031
select dataitemid,companyId,estimateperiodid, count(prasad)from #prasad_tbl
group by companyId,dataitemid,estimateperiodid,prasad
here the dataitemids are different that is why you are getting count(vid) as 1. if u want count (vid), now you figure out, you need to find the count(vid) with reference to which other column.
April 28, 2011 at 1:02 pm
10
April 28, 2011 at 1:03 pm
Thank you i got it
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply