Question

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

Was it helpful?

Solution

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

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top