开发者社区> 问答> 正文

统计每年每月的信息year month amount

统计每年每月的信息 year month amount 1991 1 1.1 1991 2 1.2 1991 3 1.3 1991 4 1.4 1992 1 2.1 1992 2 2.2 1992 3 2.3 1992 4 2.4 查成这样一个结果 year m1 m2 m3 m4 1991 1.1 1.2 1.3 1.4 1992 2.1 2.2 2.3 2.4

展开
收起
茶什i 2019-11-13 18:56:49 1450 0
1 条回答
写回答
取消 提交回答
  • 答案一: select sales.year , (select t.amount from sales t where t.month=‘1’ and t.year= sales.year) ‘1’, (select t.amount from sales t where t.month=‘1’ and t.year= sales.year) ‘2’, (select t.amount from sales t where t.month=‘1’ and t.year= sales.year) ‘3’, (select t.amount from sales t where t.month=‘1’ and t.year= sales.year) as ‘4’ from sales group by year; 答案二:

    SELECT sales.year,GROUP_CONCAT(CONCAT(sales.year,’:’,sales.amount)) FROM sales GROUP BY sales.year

    2019-11-13 18:57:03
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载