× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello,

If not the correct list to send this question to please let me know which one.


I need help with improving/simplifying this SQL statement:

SELECT substr(idept,1,1) as lineSeq, dpdesc, min(dhloc) as location, sum(dhsell*dhqty) + Sum(aSell * aQty) as Sales_Amt, sum(dhcost*dhqty) + Sum(aCost * aQty) as Cost_Amt,
(cast( ( sum(dhsell*dhqty) + Sum(aSell * aQty) ) - (sum(dhcost*dhqty) + Sum(aCost * aQty)) as double) / cast(sum(dhcost*dhqty) + Sum(aCost * aQty) as double)) as Margin

from dbslsdlg left join KCX340D.dbprodpf on dhino = ino
Left Join DBSLSDXL1 b on aINo = ino
Left join dbdeptpf on substr(idept,1,1) = deptno
where dhdate >= 20150701 and dhdate <= 20150730
AND aDate >= 20150701 and aDate <= 20150730
group by substr(idept,1,1), dpdesc order by 1, dpdesc;

Thank you
Art Duarte


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.