我正在开展一个项目,我必须在其中展示产品和数量。
这是我的疑问:
select DATEDIFF(month,T3.startdate,T3.enddate) warranty_duration,
T2.ItemCode,T2.Quantity,T2.SerialNum,T4.ItemName,T2.SerialNum as
InternalSN,T3.ContractID,T3.issend,
T3.StartDate,T3.EndDate,T3.Remarks1 from ORDR T1
inner join RDR1 T2 on T1.DocEntry=T2.DocEntry
inner join OCTR T3 on T1.CardCode=T3.CstmrCode
inner JOIN OITM T4 ON T2.ItemCode=T4.ItemCode
WHERE (DATEDIFF(day,getdate(),T3.enddate)<=7 and
DATEDIFF(day,getdate(),T3.enddate)>=0)
and T3.isSend=0
and T4.SWW in ('PSG','IPG-H','ESSN-N','ESSN-ISS','ESSN-HPN','ESSN-
BCS','EABMS')
and t3.contractID = 23890
我的查询显示如下结果:
我想这样表现出来:
答案 0 :(得分:1)
select DATEDIFF(month,T3.startdate,T3.enddate) warranty_duration,
T2.ItemCode,T2.Quantity,T2.SerialNum,T4.ItemName,T2.SerialNum as
InternalSN,T3.ContractID,T3.issend,
T3.StartDate,T3.EndDate,T3.Remarks1 from ORDR T1
inner join RDR1 T2 on T1.DocEntry=T2.DocEntry
inner join OCTR T3 on T1.CardCode=T3.CstmrCode
inner JOIN OITM T4 ON T2.ItemCode=T4.ItemCode
WHERE (DATEDIFF(day,getdate(),T3.enddate)<=7 and
DATEDIFF(day,getdate(),T3.enddate)>=0)
and T3.isSend=0
and T4.SWW in ('PSG','IPG-H','ESSN-N','ESSN-ISS','ESSN-HPN','ESSN-
BCS','EABMS')
and t3.contractID = 23890
GROUPBY T2.ItemCode
答案 1 :(得分:0)
GROUP BY productName
(在数据库中将粗体值更改为您自己的值)应该可以解决问题。