SQL select values sum same ID

后端 未结 4 1860
难免孤独
难免孤独 2021-02-05 15:35

This is my Table called "SAM"

ID  |   S_Date   |  S_MK |   TID   |   Value   |
===============================================
1   | 2012-12-11 |   1            


        
4条回答
  •  故里飘歌
    2021-02-05 16:14

    If you really need this result set, with grouping only by T_ID, you can use this query:

    SELECT   (SELECT top 1 S_Date FROM SAM as t1 WHERE t1.TID = t2.TID) as S_Date,
             TID,
             SUM(Value) 
    FROM     SAM as t2
    GROUP BY TID
    

提交回复
热议问题