我有這個疑問SQL三個表連接查詢
select
dbo.CLOI_ClientOrderItems.cl_id,
count(dbo.IN_Invoices.MasterOrderId) as Orders,
sum(dbo.IN_Invoices.in_total) as Total
from
IN_Invoices
inner join
CLOI_ClientOrderItems
on
IN_Invoices.MasterOrderId=CLOI_ClientOrderItems.MasterOrderId
where
datepart(mm,in_date_issued)=2
and
datepart(yyyy,in_date_issued)=2014
group by
cl_id
select
sum(in_total)
from
IN_Invoices
where
datepart(mm,in_date_issued)=2
and
datepart(yyyy,in_date_issued)=2014
從這個查詢我得到的in_total結果,並使用此查詢我需要顯示cl_id和計數(順序)
你能描述你想要的輸出嗎? – jpw
你的第一個查詢doosen't工作? –
cl_id訂單總數 100000_ori 4 476 bur其錯誤 – user3445262