SQL Query question

  • a1 and a2 have same structure, but a1 has more records than a2. so, in order to find out how many records are missing in a2 the below query works. but is there a way to write the below query using joins.

    Select * from a1 where stoptime not in (select stoptime from a2)

    please

  • select a1.* from a1 left join a2 on a1.stoptime = a2.stoptime where a2.stoptime is null

    This would also work for tables without the same structure, as long as the tables can be joined on with a foreign key field(s).

     

    Kathi

     

     

     

    Aunt Kathi Data Platform MVP
    Author of Expert T-SQL Window Functions
    Simple-Talk Editor

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply