ukerandi
asked on
SQL query
Hi
Please attached my file and see below
sql, I'm getting after run following sql 0, can anyone explain where iam doing mistake.
Results is zero.
Main sql code
zero results for SalesTotal
But if I run like that without main code its working fine, please show me where iam doing mistake in main SQL
Please attached my file and see below
sql, I'm getting after run following sql 0, can anyone explain where iam doing mistake.
Results is zero.
Main sql code
select SUM(inall.price *inall.qty_invoiced),ROUND(SUM((Case when inall.qty_invoiced=0 then art.amount else ((inall.price *inall.qty_invoiced)/hdr.exch_rate) end)),2) as SalesTotal,
hdr.slsman,MONTH(hdr.inv_date) as SalesMonth,hdr.co_num
from inv_hdr hdr
INNER JOIN inv_item_all inall ON hdr.inv_num=inall.inv_num
LEFT OUTER JOIN artran art ON hdr.inv_num=art.inv_num
Left outer join custaddr custadd ON hdr.cust_num= custadd.cust_num
LEFT Outer Join coitem co ON custadd.cust_num=co.cust_num
where YEAR(hdr.inv_date)= YEAR(getdate()) and (hdr.slsman ='F000001' and hdr.co_num='SFT0003575' ) and art.type in('I','C') and (MONTH(hdr.inv_date))=2
and (SUBSTRING( co.non_inv_acct,1,1)=5 or co.non_inv_acct is null)
and custadd.cust_seq=0
group by (MONTH(hdr.inv_date)),hdr.slsman,hdr.co_num
zero results for SalesTotal
But if I run like that without main code its working fine, please show me where iam doing mistake in main SQL
select sum((qty_invoiced* price)/7.47) as Total from inv_item_all where co_num='SFT0003575'
group by co_num
Sqlhelp.xlsx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.