當前位置:首頁 » 編程語言 » 勝負sql

勝負sql

發布時間: 2022-08-11 20:56:28

sql子查詢,分別統計出每支隊伍的勝負次數

select a.iwu ,a.勝,b.負 from
(select count(*) 勝, iwu from tabb where shengfu='勝' group by iwu ) a left join
(select count(*) 負, iwu from tabb where shengfu='負' group by iwu ) b on a.iwu=b.iwu

--sql2000調試通過,可以自己用case when改寫一下

Ⅱ 用sql語言實現

是用SUM() 函數
SUM 函數返回數值列的總數(總額)。

select 姓名,
Sum(Case when 勝負='勝' then 1 Else 0 End) 勝,
Sum(Case when 勝負='負' then 1 Else 0 End) 負
from 表1 group by 姓名

這個你看下可以不

Ⅲ 關於sql語句查詢的問題

如原表有2列,時間和勝負,語句:
select 時間,sum(case when 勝負='勝' then 1 else 0 end) 勝,sum(case when 勝負='負' then 1 else 0 end) 負 from 表
group by 時間

Ⅳ sql查詢語句,ABC三隻球隊各有勝負,要生成下面的表該怎麼辦


SELECTteam,SUM(CASEresultWHEN'勝'THEN1ELSE0END)ASwin,SUM(CASEresultWHEN'負'THEN1ELSE0END)asloss
FROM原表A
GROUPBYteam

Ⅳ sql 語句查詢

select隊名,
sum(casewhen勝負欄位='勝'then1else0end)勝,
sum(casewhen勝負欄位='負'then1else0end)負
from表名
groupby隊名

你把相應的欄位名和表名改一下就OK

Ⅵ 怎樣寫SQL語句結果是這樣的

select日期,
sum(casewhen勝負=N'勝'then1else0end)as勝,
sum(casewhen勝負=N'負'then1else0end)as負
from表
groupby日期

Ⅶ 要求查詢得到結果,寫出sql語句

select tab2.日期,
(select count(1) from tab where tab.勝負 = '勝' and tab2.日期 = tab.日期),
(select count(1) from tab where tab.勝負 = '負' and tab2.日期 = tab.日期)

from
(select distinct 日期 from tab) tab2

Ⅷ SQL語句怎麼寫

select D.date,D.WIN as '勝',E.lose as '負'
from
(select date,win from(
SELECT date,
case when result = '勝' then count(result) else 0 end as 'win',
case when result = '負' then count(result) else 0 end as 'lose'
from T3
group by date,result
) C
where win > 0
group by date,C.win,C.lose) D,
(select date,lose from(
SELECT date,
case when result = '勝' then count(result) else 0 end as 'win',
case when result = '負' then count(result) else 0 end as 'lose'
from T3
group by date,result
) C
where lose > 0
group by date,C.win,C.lose) E
where E.date = D.date

-------------------------結果---------------

結果如下
date 勝 負
2007-07-01 00:00:00 2 2
2007-08-01 00:00:00 1 2

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:645
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:936
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:632
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:821
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:731
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1066
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:299
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:160
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:851
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:763