SQL syntax that returns columns from 2 rows of the same table on the same result row. SQL Server 2005
Posted on 2007-10-05
Need a SQL statement that returns columns from 2 rows of the same table on the same result row.
I have a Primary key, QuoteDate and Cl.osePrice column in a SQL Server 2005 table.
I need a SQL statement that returns the QuoteDate and ClosePrice for two given dates.
SELECT (QuoteDate on '09/15/2007') As PreviousDate, (ClosePrice on '09/15/2007') As PreviousPrice,
(QuoteDate on '09/30/2007') As RecentDate, (ClosePrice on '09/302007') As RecentPrice
WHERE PrimnaryKey = Value
What are the expressions for PreviousDate, etc.?