Oracle SQL - Comparing Rows -


i have problem i'm working on oracle sql goes this.

table

 purchaseid    custid      location   ----1------------1-----------a   ----2------------1-----------a     ----3------------2-----------a   ----4------------2-----------b   ----5------------2-----------a   ----6------------3-----------b   ----7------------3-----------b   

i'm interested in querying table return instances same customer makes purchase in different locations. so, table above, want:

output

purchaseid    custid      location   ----3------------2-----------a   ----4------------2-----------b   ----5------------2-----------a   

any ideas on how accomplish this? haven't been able think of how it, , of ideas seem pretty clunky. database i'm using has 1mm+ records, don't want run slowly.

any appreciated. thanks!

select * yourtable t custid in (select custid                  yourtable                  group custid                  having min(location) <> max(location)) 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -