使用SUM()为Qty列删除重复条目 [英] Remove duplicate entry using SUM() for Qty column

查看:120
本文介绍了使用SUM()为Qty列删除重复条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想截断重复行但是应该添加数量



我有一张装有数据的表格,



Hi,

I want to truncate duplicate rows but Qty should be added

I have a table filled with data,

Item   Qty   MinQty   MaxQty
ABC	10    20        50
XYZ     12    30        40
ABC     15    20        50





我想要的结果如下,



I want the result like,

Item   Qty   MinQty   MaxQty
ABC	25    20        50
XYZ     12    30        40





请帮助我写相同的查询...



Kindly help me to write the query for the same...

推荐答案

Select Item, sum(Qty) as Qty, MinQty, MaxQty
from <your table>
Group by Item, MinQty, MaxQty


以下语句将使用 GROUP BY [ ^ ]子句:



As Maciej指出需要从group by子句中删除Qty列。 [/ Edit]

The following statement will work by using a GROUP BY[^] clause:

As Maciej pointed out the Qty column needed to be removed from the group by clause.[/Edit]
SELECT tab.Item, SUM(tab.Qty) as Qty, tab.MinQty, tab.MaxQty
FROM   WhatEverNameYourtTableMayHave as tab
GROUP BY tab.Item, tab.MinQty, tab.MaxQty





MinQty和MaxQty将必须是相同的,但每个离散项目四个。



问候,

- Manfred


感谢你的回复,你的查询工作正常我...我正在寻找dat结果。你们节省了我的时间。
Thanks for ur kind reply, ur query working fine for me.. i was looking for dat result. u guys saved my time.


这篇关于使用SUM()为Qty列删除重复条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆