cancel
Showing results for 
Search instead for 
Did you mean: 

Query Ventas por vendedor por mes

0 Kudos

Estimados

Estoy buscando hacer una query de ventas por vendedores y por mes para todo el año.

Me podrian ayudar? ademas que tiene que ser en Hana.

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

tenho em SQL

SELECT *
FROM(SELECT
      CASE MONTH(T0.[DocDate])
      WHEN 1 THEN 'Jan'
      WHEN 2 THEN 'Fev'
      WHEN 3 THEN 'Mar'
      WHEN 4 THEN 'Abr'
      WHEN 5 THEN 'Mai'
      WHEN 6 THEN 'Jun'
      WHEN 7 THEN 'Jul'
      WHEN 8 THEN 'Ago'
      WHEN 9 THEN 'Set'
      WHEN 10 THEN 'Out'
      WHEN 11 THEN 'Nov'
      WHEN 12 THEN 'Dez'
    END as [Month],
T2.[SlpName] as [Name],
T1.[LineTotal] as [Amount]
FROM ORDR T0
INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode
INNER JOIN OITB T4 ON T3.ItmsGrpCod = T4.ItmsGrpCod
Where Year(T0.[DocDate] ) = 2019 AND T0.CANCELED = 'N')
WorkOrders
PIVOT
(
  SUM([Amount])
  FOR [Month] IN (
    [Jan],[Fev],[Mar],[Abr],
    [Mai],[Jun],[Jul],[Ago],
    [Set],[Out],[Nov],[Dez]
  )
) AS PivotTable
ORDER BY [Name]