|
|
|
Hi all. I have tried making this query for a while and i didn't manage to. I know it is something related to JOIN, but i didn't manage to make it work :\ I have two tables. Table1- db_stockprices Table2- db_stockSymbols
db_stockprices is getting updated every day with stock daily prices. db_stockprices looks like: ID, SymbolID, Price,Date 1 1 33.21 1/1/2007 2 1 33.14 1/2/2007 3 1 34.21 1/3/2007 4 2 11.42 1/1/2007 5 2 11.73 1/2/2007 6 3 18.32 1/1/2007 7 3 19.11 1/2/2007 8 3 18.41 1/3/2007 9 4 52.44 1/1/2007
and so on for all the stocks. ID is Primary Key SymbolID is related to SymbolID in db_stockSymbols which contains all the stock information.
What i am trying to do is an SQL QUERY that will delete all same SymbolID Rows if a specific INPUT date do not exist within that SymbolID.
Example: If the INPUT date for the query is 1/3/2007 all rows with SymbolID "2" abd "4" will be deleted since 1/3/2007 does not exist in SymbolID "2" and "4". Moreover, the row in db_stockSymbols with SymbolID "2" and "4" will also be deleted.
Is this possible within 1 SQL Query I would really appreciate a good query example for this example.. |