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

熱點內容
javac哪個好學 發布:2025-10-16 10:31:51 瀏覽:629
全國各地區dns伺服器地址大全 發布:2025-10-16 10:13:34 瀏覽:488
伺服器如何添加聯想de存儲 發布:2025-10-16 09:30:39 瀏覽:927
站群伺服器ip怎麼解析 發布:2025-10-16 09:25:06 瀏覽:473
編程打古詩 發布:2025-10-16 09:17:51 瀏覽:643
python正態隨機數 發布:2025-10-16 09:13:27 瀏覽:211
新建域用戶如何保存原來的配置 發布:2025-10-16 09:05:01 瀏覽:967
安卓相機怎麼調出蘋果相機的效果 發布:2025-10-16 08:56:21 瀏覽:693
我的世界大伺服器列表 發布:2025-10-16 08:50:09 瀏覽:445
如何找回發票軟體用戶名密碼 發布:2025-10-16 08:35:54 瀏覽:305