sql server 2005 - T-SQL Query Self join via Date Table -


i trying write query joins table via date table. date table populated day per row dates on 200 years (don't ask didn't design it). has column date , 1 previous working date (i.e. if monday prev date previous friday).

the other table lets call prices has date column , id determine type of price comes once each day. need join prices against via date table have each day alongside previous day using type column determine ones belong each other.

todays date | todays price | previous working day date | previous working day price | price type 

any ideas?

maybe this:

select   today.date,   today.price,   yesterday.date,   yesterday.price,   today.pricetype price today   inner join dates d on today.date = d.date   inner join price yesterday     on d.yesterdaydate = yesterday.date , today.pricetype = yesterday.pricetype 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -