Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Distinct values query

ASP_007Nov 16 2016 — edited Nov 16 2016

Dear Members,

need some help on sql query, where I am trying to fetch distinct header_id from given list. Below is the example query., where i am getting 22 distinct ID's from those I hard coded in class. so out of those 62 id's from IN cluase i am able to see 22 records which are in table. This table has million of distinct header ID's and these are some header_ids that i am anlysing for some business logic. Now I need to quickly identify header_id's other than 22 which are there in IN clause. That means I need to find what are the ID's not there in IN clause and available in table and what are ID's that are not in IN clause. I understandIN operator means ANY of elements that are being compared, The trick thing for me to find out the ODD from hardcoded list rather checking in table.

database version : 12c

select

  distinct header_id

from

activity_stg

where

header_id in(125601,13763,144680,1711699,1737545,1743806,1743809,1747127,1752135,1756128,1766208,1767896,193247,

               218594,233174,239895,285000,29276,311001,328238,361057,362410,373934,3754,381598,392436,398067,

               414329,423704,435455,473540,486745,499978,504150,507599,510280,5274,527998,533416,54408,588304,596155,

               604460,607914,610628,611786,61279,64759,660408,675444,677452,679047,717810,731201,739186,745764,

               757505,765275,806080,86161,93390,94136);

best regards

asp

This post has been answered by BrunoVroman on Nov 16 2016
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 14 2016
Added on Nov 16 2016
9 comments
884 views