Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Query Help

Hi,

I'm try to do a query that give me quotes number, invoices number, new clients number , total clients number....all this by salesname and dates ranges.

Something like this:

                                              JAN                                                                        FEB

SalesName |  #quotes | #Invoice | #NewClient | #qutoes | #Invoices | #NewClients | .........................

I have problems with unions

Query invoices:

SELECT DISTINCT T2.[SlpName],(T0.DocNum) as 'Facturas' FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode WHERE T1.[TargetType] <>'14' and  T0.[DocDate] >=[%0] AND  T0.[DocDate] <=[%1]

later a count.

Query quotes:

SELECT DISTINCT T2.[SlpName],(T0.DocNum) as 'Cotizaciones' FROM OQUT T0  INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode WHERE T1.[TargetType] <>'14' and  T0.[DocDate] >=[%0] AND  T0.[DocDate] <=[%1]

Query number of clients :

SELECT    T0.SlpName, COUNT(T1.CardCode) AS NumClientes

FROM         OSLP AS T0 INNER JOIN

                      OCRD AS T1 ON T0.SlpCode = T1.SlpCode

Query New Clients last 6 months (i prefer this bi dates range)

SELECT     T0.slpName, Count(T1.CardName) AS Clientes

FROM         OSLP AS T0 INNER JOIN

                      OCRD AS T1 ON T0.SlpCode = T1.SlpCode

WHERE      (T1.CreateDate >= GETDATE() - 180)

I Need make a unique query.

Can someone help me, thanks.

Former Member
Not what you were looking for? View more on this topic or Ask a question