Help with SQL query

Discussion in 'Automated Trading' started by nitro, Oct 7, 2007.

  1. nitro

    nitro

    I have two tables:

    Table 1, Symbols, contains a colum for the stock symbol. Table 2, Weights, also contains a column for the stock symbol.

    Somehow, when I was entering values into an excel spreadsheet that I later imported into MSFT SQL server, I accidentally typed in duplicate symbols into the Weights table.

    Is there a sql query that I can use that will return symbols in the Symbols table that are missing from Weights table?

    I tried this but the sql interpreter doesn't like it:

    Code:
    select	Symbols.symbol
    from 
    	Symbols  inner join Weights on 	
    	Weights.symbol = Symbols.symbol
    where
    	 Symbols.symbol is not in Weights.symbol
    Thanks.

    nitro
     
  2. Bowgett

    Bowgett

    How about using "left outer join"

    select symbols.symbol, weights.weight
    from
    symbols left outer join weights on
    weights.symbol = symbols.symbol
    where
    weights.weight is null
     
  3. nitro

    nitro

    I think that did it!!!

    Code:
    select symbols.symbol, weights.symbol
    from 
    symbols left outer join weights on 
    weights.symbol = symbols.symbol
    where
    weights.symbol is null
    
    Thanks :cool: