Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting different scenarios from minus table
    primarykey
    data
    text
    <p>I have this two tables:</p> <p>Table A</p> <pre> ID TYPE SDATE EDATE RATING 1 M 1/1/2010 1/1/2011 A 1 M 1/3/2010 1/4/2011 B 2 A 7/2/2010 1/31/2015 C 3 M 3/1/2011 1/20/2012 B 4 A 3/1/2011 1/20/2012 B 5 M 3/1/2009 3/1/2009 F 6 M 12/31/2006 12/31/9999 A 7 A 1/1/2006 12/31/9999 B </pre> <p>Table B</p> <pre> ID TYPE SDATE EDATE RATING 1 M 1/1/2010 1/1/2011 A 2 A 7/2/2010 1/31/2015 C 2 A 9/2/2010 1/31/2015 C 3 M 3/1/2011 1/20/2012 B 4 A 3/1/2011 1/20/2012 C 6 M 12/31/2006 12/31/2015 A 7 A 2/1/2006 12/31/9999 B 8 M 1/2/2010 1/2/2012 </pre> <p>When I perform a table A minus table B, it gets me the next result:</p> <pre> ID TYPE SDATE EDATE RATING 1 M 1/3/2010 1/4/2011 B 4 A 3/1/2011 1/20/2012 B 5 M 3/1/2009 3/1/2009 F 6 M 12/31/2006 12/31/9999 A 7 A 1/1/2006 12/31/9999 B </pre> <p>I have already identified the case where A.id is not in B.id, but how do I check when it is different in some other column?</p> <p>I'm not allowed to create anything on the schema, so I have to do it through queries.</p> <p>So far, this is what I have, but it gives me data that is not correct.</p> <pre> <code> with aminusb as ( select * from A minus select * from B ) select diff.* from aminusb diff ,B where diff.id = B.id and diff.start_date = B.start_date and diff.end_date = B.end_date and diff.rating &lt;&gt; B.rating </code> </pre> <p>Do you know how could I get the different scenarios?</p> <ul> <li>When everything is equal but, rating.</li> <li>When everything is equal but, end date.</li> <li>When nothing is equal but, it has the same id.</li> </ul> <p>I need to get a list of the records that fulfill every scenario so people can check it on detail.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload