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

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

Azure DocumentDB Owner resource does not exist

SQL Server 2008 - High Memory Usage