亲爱的所有..我在DB中有这个数据:
line model serial
fa01 kd-g335ud 105x0001
fa01 kd-g335ud 105x0002
fa01 kd-g335ud 105x0003 //up to 20pcs or regardless of the number of goods in the db
fa02 kd-r311ed 105x0001
fa02 kd-r311ed 105x0002 //up to 20pcs or regardless of the number of goods in the db
我希望如果每个“型号”达到20个或者无论数据库中的商品数量是多少,数据都会显示在数量页面上:
line model qty
fa01 kd-g335ud 20
fa02 kd-r311ed 20
请帮助,谢谢之前: - )
答案 0 :(得分:2)
SELECT line, model, count(serial) as qty FROM table_name GROUP BY line, model
我的查询不是100%肯定,但这与你想要的一致。希望这个查询是正确的!
答案 1 :(得分:0)
SELECT model, count(model) AS QUANITY FROM [table name] GROUP BY model;