Ê×ÏÈ´´½¨²âÊÔ±í¡¢Ìí¼ÓÊý¾Ý¡£
create table #t(a int,b int,c int,d int,e int)
insert into #t values(1,2,3,4,5)
insert into #t values(1,2,3,4,6)
insert into #t values(1,2,3,4,7)
insert into #t values(1,2,3,4,8)
insert into #t values(1,3,3,4,5)
insert into #t values(1,3,3,4,6)
insert into #t values(1,3,3,4,8)
insert into #t values(1,3,3,4,7)
insert into #t values(2,2,2,4,5)
insert into #t values(2,2,3,4,6)
insert into #t values(2,2,4,4,7)
insert into #t values(2,2,5,4,8)
insert into #t values(2,3,6,4,5)
insert into #t values(2,3,3,4,6)
insert into #t values(2,3,3,4,8)
insert into #t values(2,3,3,4,7)
Çé¿öÒ»£ºÖ»ÓÐÒ»¸ö·ÖÀà»ã×ÜÁÐʱ£¬Ö»ÐèÒªÒ»¸öºÏ¼Æ¡£Ö»ÐèÒªÔö¼Ówith rollup¼´¿É¡£
select case when grouping(a)=1 then 'ºÏ¼Æ' else cast(a as varchar) end a,
sum(b),sum(c),sum(d),sum(e) from #t group by a with rollup
Çé¿ö¶þ:Óжà¸ö·ÖÀà»ã×ÜÁУ¬Ö»ÐèÒªÒ»¸öºÏ¼Æ.Ôö¼ÓrollupÖ®ºó£¬ÐèÒªÔö¼ÓÅжϡ£
select case when grouping(a)=1 then 'ºÏ¼Æ' else cast(a as varchar) end a,
b,
sum(c),sum(d),sum(e) from #t
group by a,b with rollup
having grouping(b)=0 or grouping(a)=1
select case when grouping(a)=1 then 'ºÏ¼Æ' else cast(a as varchar) end a,
b,
c,
sum(d),sum(e) from #t
group by a,b,c with rollup
having grouping(c)=0 or grouping(a)=1
Çé¿öÈý£ºÓжà¸ö·ÖÀà»ã×ÜÁУ¬ÐèҪȫ²¿µÄС¼ÆºÍºÏ¼Æ¡£
select case when grouping
The aspnet_Profile table contains the following fields: UserId, PropertyNames, PropertyValuesString, PropertyValuesBinary, and LastUpdatedDate. The PropertyNames field contains a string delimited with colons (:) that identify which profile fields are stored, what their datatype is and their of ......