We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f7ade1b commit bc62977Copy full SHA for bc62977
Advanced SQL Puzzles/Advanced SQL Puzzles Solutions.sql
@@ -975,6 +975,20 @@ FROM cte_ValidPrices
975
WHERE Rnk = 1;
976
GO
977
978
+--Solution 3
979
+--MAX
980
+WITH cte_MaxEffectiveDate AS
981
+(
982
+SELECT ProductID,
983
+ MAX(EffectiveDate) AS MaxEffectiveDate
984
+FROM #ValidPrices
985
+GROUP BY ProductID
986
+)
987
+SELECT a.*
988
+FROM #ValidPrices a INNER JOIN
989
+ cte_MaxEffectiveDate b on a.EffectiveDate = b.MaxEffectiveDate AND a.ProductID = b.ProductID;
990
+GO
991
+
992
/*----------------------------------------------------
993
Answer to Puzzle #21
994
Average Monthly Sales
0 commit comments