文章詳情頁
關(guān)于Mysql數(shù)據(jù)表行轉(zhuǎn)列
瀏覽:158日期:2022-06-13 14:39:16
問題描述
問題解答
回答1:試試下面的語句:
select team_name,sum(if(score=’正’,1,0)) as’正’,sum(if(score=’負(fù)’,1,0)) as ’負(fù)’ from teamscore group by team_name;回答2:
應(yīng)該是:
SELECT team_name, count(*) AS win WHERE score = ’正’ GROUP BY team_nameSELECT team_name, count(*) AS loss WHERE score = ’負(fù)’ GROUP BY team_name
再想辦法把這兩個(gè)結(jié)果合起來。
上一條:數(shù)據(jù)庫 - MySQL 單表500W+數(shù)據(jù),查詢超時(shí),如何優(yōu)化呢?下一條:mysql - php 如何網(wǎng)址中出現(xiàn)該頁標(biāo)題?
相關(guān)文章:
1. html - 自學(xué)php 遇到代碼不執(zhí)行直接在網(wǎng)頁上顯示 望各位大神不吝賜教2. html - node-module文件有兩個(gè)在我的項(xiàng)目文件里3. 這段代碼是獲取百度收錄量的!需要怎么設(shè)置才能獲取百度快照旁邊的網(wǎng)址呢?4. 這是什么情況???5. android-studio - android studio如何設(shè)置默認(rèn)打開歡迎頁而不是最近的項(xiàng)目?6. 微信小程序的選項(xiàng)卡中的數(shù)據(jù)分頁加載卡頓問題???7. linux - ngxin配置后,網(wǎng)頁打不開8. Android Studio 中 xUtils 3.0 替換 2.0 的時(shí)候總報(bào)找不到 jar 包是什么原因?9. 數(shù)據(jù)表里沒數(shù)據(jù)顯示10. mysql如何配置遠(yuǎn)程php外網(wǎng)鏈接數(shù)據(jù)庫
排行榜

熱門標(biāo)簽