Expanded analytic patterns -- SQL queries