sql server - SQL Query to find missing records between two tables that share a key -
just title asks trying find way give me number difference in transactions. question in plain english is: there bad data in database. sales transactions missing data on product , how many sold.
salestransaction (table 1) columns: transactionid, customerid, storeid, tdate
soldvia (table 2) columns: transactionid, productid, noofitems
any on appreciated. if being unclear let me know , provide more info. thank you.
this simple left join
filtering null
s:
for missing items in soldvia
table:
select count(*) difference salestransaction st left join soldvia s on st.transactionid = s.transactionid s.transactionid null
for missing items in both tables:
select count(*) difference salestransaction st full join soldvia s on st.transactionid = s.transactionid st.transactionid null or s.transactionid null
Comments
Post a Comment