Domanda

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

È stato utile?

Soluzione

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

Altri suggerimenti

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top