开发者

getting problem in group by clause

开发者 https://www.devze.com 2023-01-22 05:21 出处:网络
i want to get the sum of quantity from the below query. how i write the group by clause in below mention query.

i want to get the sum of quantity from the below query. how i write the group by clause in below mention query.

select top 1 
EvrId,
TimeStamp,
Date,
BnhTnkMik1 as Quantity,
(select TnkCode from Tanklar where TnkId=BnhTnkId) as Tank,
FuelCode,
InvoiceNo from Evrak 
join Hareket on开发者_JS百科 (BnhEvrId=EvrId)
join Stoklar on (StokId=BnhStok) 
where EvrTip=14 and EvrStatu='A'


select top 1 
  EvrId, 
  TimeStamp, 
  Date, 
  SUM(BnhTnkMik1) as Quantity, 
  (select TnkCode from Tanklar where TnkId=BnhTnkId) as Tank, 
  FuelCode, 
  InvoiceNo 
 from 
  Evrak 
  join Hareket on (BnhEvrId=EvrId)
  join Stoklar on (StokId=BnhStok)
  where EvrTip=14 and EvrStatu='A'
 GROUP BY 
  EvrId, 
  TimeStamp, 
  Date, 
  (select TnkCode from Tanklar where TnkId=BnhTnkId), 
  FuelCode, 
  InvoiceNo 


select  
    EvrId,
    sum(BnhTnkMik1) as Quantity,
from Evrak 
join Hareket on (BnhEvrId=EvrId)
join Stoklar on (StokId=BnhStok) 
where EvrTip=14 and EvrStatu='A'
group by 
    EvrId
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号