October 22, 2024
Chicago 12, Melborne City, USA
SQL

Get the non-matching rows in SQL


We have two SQL tables

table_1 and table_2.

Now, We have to do a merger of these two table in such a way that, table_1 seq_number which is not present in table_2, map with the tp_no = 0 Like this.

output_table

We have to create this in SQL table so it could be used further.

I am trying to achieve this by:

select distinct tar.c_Id,brd.Toucpoint,brd.sequence_number,tar.tot_Id,tar.tp_no
from table_2 tar 
inner join (
     select distinct c_Id,channel,sequence_number
     from table_1
) brd on tar.c_Id = brd.c_Id and tar.tp_no <> brd.sequence_number
where tar.tp_no = '0';

But this is not giving the desired output.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video