Skip to Content

Help with SQL query

I keep getting stumped on trying to build out a new query. Requirements are any customer BP in SAP B1 with either one quote or one order or one invoice (1 record in OQUT or 1 record in ORDR of 1 record in OINV or two of three or three of three) Need to run this nightly and present to sales people for followup. It's pretty much to identify new BP's. So far I have

SELECT CardCode, 'Q' as 'ID' FROM OQUT Group By CardCode HAVING Count(DocNum) = 1

UNION ALL SELECT

CardCode, 'O' as 'ID' FROM ORDR Group By CardCode HAVING Count(DocNum) = 1

UNION ALL

SELECT CardCode, 'I' as 'ID' FROM OINV Group By CardCode HAVING Count(DocNum) = 1

The format needs to be BP quote/order/invoice # Dollar amt. Ship to Address Rep . Rep is a custom table that hold the sales rep by zipcode.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.