求sql語句,求!!!SQL語句!

時間 2022-02-28 04:45:31

1樓:

隨緣寫法你看是你要的不,實際上要是已經是1和0了 直接sum也行select  a1,sum(a2),sum(a3) from a group by a1

2樓:匿名使用者

既然已經是1和0了,那麼直接sum就可以了

select place,sum(tdbz),sum(xdbz) from table group by place

3樓:匿名使用者

如果表資料除了0就是1的話,可以分組,在將各個欄位求和sql如下:

select id1,sum(data1),sum(data2) from test1 group by id1

若有0,1之外的資料,就先查出數值是1的資料,在進行分組統計,sql如下:

select id1,sum(data1),sum(data2) from test1 where data1=1 or data2=1 group by id1 ;

求!!!sql語句!

mysql求大神優化sql語句

可以這樣寫成只使用1個子查詢 select a.b.d as day num,b.m as month num,b.y as year num from watersku a,select sum b.num as y,sum case when date format b.add time,y m...

高分求SQL語句,要求如下

下面的語句看起來好像有道理,但是在我的資料庫系統不支援,不知道你的資料庫系統怎樣,祝你好運 select top 15 from select top 3 from t article where special 業內 order by id desc union select top 3 from...

sql語句中,SQL語句中USE

三歲喝酒 use pubs 選擇 名字 pubs 的資料庫 select title id from sales where title id in 查詢欄位title id符合號內限定條件的表sales的 title id 列 select title id from titles where t...