Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL View

$
0
0

First off I am far from a SQL expert, so please excuse my ignorance!

I have this setup for a SQL view that is basically pulling from our ERP database. What I want it to show me is RMA orders (ordtype = A) with ItemCodes that match what I have set below. This works to some degree, but when it returns the data it ends up putting each item code against each current RMA order. If I go into the ERP system I can see that this is not the case of having each item code in the order itself. Is there something wrong with my code?

SELECT DISTINCT
MAX(ordate) AS lastordate, DATEDIFF(day, MAX(ordate), GETDATE()) AS nodays, slsno, cusno, Cusname, salesname, slsemail, manager, mgrmail, ordno, ordtype,
ItemCode
FROM dbo.v_New_RMA_Notify
GROUP BY salesname, Cusname, slsno, cusno, Cusname, slsemail, manager, mgrmail, ordno, ordtype, ItemCode
HAVING (ordtype...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>