Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Selecting only those records where there is only one row - Oraclw query

Posted on 2014-10-23
1
Medium Priority
?
377 Views
Last Modified: 2014-10-27
Experts,

I am reading a table in Oracle:
      Select   t1.CLAIM_NO
                              , t1.KICKOUT_CODE
                  , t1.cert_no
                   , t1.cost_center
                  , t1.arrv_date
       From Table1;

I would like to select only those records where there is only one row where t1.claim_no, t1.cert_no are the same.

Does anyone know how/if this can be coded as a single query?
0
Comment
Question by:morinia
1 Comment
 
LVL 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 40399879
Try this:
      Select   CLAIM_NO
                   ,KICKOUT_CODE
                   ,cert_no
                   ,cost_center
                   ,arrv_date
from(
      Select   t1.CLAIM_NO
                   , t1.KICKOUT_CODE
                   , t1.cert_no
                    , t1.cost_center
                   , t1.arrv_date
                  , count(*) over(partition by claim_no, cert_no) mycount
        From Table1
)
where mycount=1;
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question