Select multiple columns from a table, but group by one

后端 未结 11 1441
逝去的感伤
逝去的感伤 2020-12-12 14:54

The table name is \"OrderDetails\" and columns are given below:

OrderDetailID || ProductID || ProductName || OrderQuantity

I\'m trying to s

11条回答
  •  悲哀的现实
    2020-12-12 15:37

    I use this trick for to group by one column when I have a multiple columns selection:

    SELECT MAX(id) AS id,
        Nume,
        MAX(intrare) AS intrare,
        MAX(iesire) AS iesire,
        MAX(intrare-iesire) AS stoc,
        MAX(data) AS data
    FROM Produse
    GROUP BY Nume
    ORDER BY Nume
    

    This works.

提交回复
热议问题