Pergunta

SQL for identifing the following query?

Which month shows the greatest amount of total dollars spent on travel and entrainment by customers in each region?

enter image description here

Foi útil?

Solução

Based on the requirement.

By using the Join Condition we can achieve the desired result.

Please go through the query.

select L.Region,T.Month,SUM(F.Amount) as Amount_Spent from Fact_Table F Inner join time_table T on F.timekey = T.timekey Inner join Location_table L on F.LocationKey = L.Locationekey where f.purchasekey = 2 Group by T.Month,L.Region

Outras dicas

Try using :

SELECT TOP 1 d.[Month]
FROM [Fact Table] t
INNER JOIN [Time Dimension] d ON d.[Time Key]=t.[Time Key]
ORDER BY t.[Amount] DESC
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top