Monthly Archives: October 2010

Crosstab query (2)

Part one here. Another way to do vertical to horizontal query. Let’s have a table with sales_id, prod_id, sales_date, and sales_amount fields. This query will return 4 latest sales_id in 3 columns: SELECT prod_id, (SELECT TOP 1 sales_id FROM table … Continue reading

Posted in SQL | Tagged | Leave a comment