سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top