當前位置:首頁 » 編程語言 » 勝負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

熱點內容
醫美大資料庫 發布:2025-07-03 15:47:07 瀏覽:355
c語言將二進制轉化為十進制 發布:2025-07-03 15:32:47 瀏覽:987
c語言幫助文檔 發布:2025-07-03 15:22:43 瀏覽:319
雙埠存儲器在情況下會發生讀寫沖突 發布:2025-07-03 15:12:54 瀏覽:270
快站資料庫 發布:2025-07-03 14:45:44 瀏覽:39
jsp獲取上傳文件路徑 發布:2025-07-03 14:44:46 瀏覽:569
php時間微妙 發布:2025-07-03 14:39:38 瀏覽:843
巨豆豆手機回復出廠密碼是什麼 發布:2025-07-03 14:35:19 瀏覽:474
演算法的三個 發布:2025-07-03 14:35:19 瀏覽:698
wcf源碼 發布:2025-07-03 14:33:54 瀏覽:863