文章詳情頁
關(guān)于Mysql數(shù)據(jù)表行轉(zhuǎn)列
瀏覽:194日期: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. mysql數(shù)據(jù)庫每次查詢是一條線程嗎?2. 看不懂你這一步的操作3. android - 如何實(shí)現(xiàn)QQ pad 點(diǎn)擊右側(cè)輸入框,只頂右側(cè)的布局,左側(cè)布局不動(dòng)4. python - scrapy url去重5. javascript - webpack1和webpack2有什么區(qū)別?6. python爬蟲 - scrapy使用redis的時(shí)候,redis需要進(jìn)行一些設(shè)置嗎?7. Python pyinstaller 打包后在其他電腦運(yùn)行失敗8. javascript - jquery hide()方法無效9. python - TypeError: tryMsgcode() takes exactly 2 arguments (0 given)10. mysql - python如何給微信小程序?qū)懞笈_(tái)?
排行榜

熱門標(biāo)簽
網(wǎng)公網(wǎng)安備