dongpao1905 2016-11-29 03:57
浏览 117
已采纳

列的MySql Group By和Sum总值,以min值显示

I have two questions:

  1. How to group and sum a column.
  2. How to displayed the result with a min sum value

I got my 1st answer here on how to group and sum the column, but I need to filter out by min amount of 100 ..

I tried

SELECT 
    member_code, SUM(product_price) as totalSales
FROM 
    src_calculation_daily
WHERE 
    totalSales > 100
GROUP BY 
    member_code

Any help is much appreciated. Thank you

  • 写回答

2条回答 默认 最新

  • dongxie5698 2016-11-29 03:59
    关注

    I think you just want a HAVING clause:

    SELECT member_code, sum(product_price) as totalSales
    FROM src_calculation_daily
    GROUP BY member_code
    HAVING totalSales > 100;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Android STD快速启动
  • ¥15 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动