how to return many sub query in a select


hi

i have subqury below

select count(weigh),sum(weigh) mytable id=120 , status=0

select count(weigh),sum(weigh) mytable id=120 , status=2

select count(weigh),sum(weigh) mytable id=120 , status=3

i want return them in query

please me

thanks 

hi vahidbakhtiary,

please refer following codes:

declare @mytable table ( 	id int, 	weigh int, 	[status] int )  insert @mytable (id,weigh,[status]) values (120,1,0) insert @mytable (id,weigh,[status]) values (120,2,0)   insert @mytable (id,weigh,[status]) values (120,1,2) insert @mytable (id,weigh,[status]) values (120,2,2)   insert @mytable (id,weigh,[status]) values (120,1,3) insert @mytable (id,weigh,[status]) values (120,2,3)  select count(weigh) counts,sum(weigh) sums,[status] @mytable id=120  group [status]


allen li
technet community support



SQL Server  >  SQL Server Data Access



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'