最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

php mysql分組后取分組中的第一條數(shù)據(jù)和最后一條數(shù)據(jù) 并且做統(tǒng)計(jì)這樣的MYSQL怎么寫呢

php mysql分組后取分組中的第一條數(shù)據(jù)和最后一條數(shù)據(jù) 并且做統(tǒng)計(jì)這樣的MYSQL怎么寫呢

PHP
慕斯王 2018-07-22 16:04:34
需要按時(shí)間分組統(tǒng)計(jì)分組后的price總和 number總合 并要取出分組中的第一個(gè)price和最后一個(gè)price的值找了好久找不到相應(yīng)的方法希望各位能指導(dǎo)一下
查看完整描述

2 回答

?
墨色風(fēng)雨

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超6個(gè)贊

時(shí)間分組,排序字段不清,姑且按price排序吧

select 
    mtime,sum(price),sum(number),
    substring_index(group_concat(price order by price),',',1) min_price,
    substring_index(group_concat(price order by price),',',-1) max_pricefrom table group by mtime;


查看完整回答
反對(duì) 回復(fù) 2018-07-29
?
汪汪一只貓

TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊

select min(price) as min_price, max(price) as max_price from (select mtime, code, sum(price) as price, sum(number) as number from table_xx group by mtime order by mtime desc) data


查看完整回答
反對(duì) 回復(fù) 2018-07-29
  • 2 回答
  • 0 關(guān)注
  • 2981 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)