dongshubang7816 2016-01-18 08:57
浏览 89

MySQL组相同的标题(行)和金钱(行)相加,但保留单独的时间戳进行排序

I have been all over the internet to find answer for this, but I can't find any. (I might be asking incorrectly?) I have a table which looks like this: enter image description here I have been using the query:

SELECT title, date, SUM(money) 
FROM payments 
WHERE username = '$username_n' and type=0 
GROUP BY title

It does the trick, and it groups the identical titles and sum up their values

enter image description here

But as you can see, it only gives me ONE date, and I would like to be able to make a slider, where I can sort the date from the date, but I can't do that if it creates only one date for each grouped title.

How can I create multiple dates, but still get rid of the duplicated titles?

  • 写回答

3条回答 默认 最新

  • duangang4940 2016-01-18 09:08
    关注

    Try this:

    SELECT title, date, SUM(money) FROM payments 
    WHERE username = '$username_n' and type=0 GROUP BY title, date(`date`);
    
    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)