Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9233507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:34:11+00:00 2026-06-18T06:34:11+00:00

I have a PL/SQL select query like, select a.sgm, b.numbr from tbl1 a, tbl2

  • 0

I have a PL/SQL select query like,

select 
    a.sgm,
    b.numbr 
from tbl1 a, tbl2 b 
where b.itemId = a.itemId 
    and b.orgId = a.orgId 
    and a.srvCode = 'F' 
    and a.nbrCode <> 1 
    and rownum <= 7

Right now it retrieves like ,

sgm-|-numbr 
-----------
abc-|-123
abc-|-678
abc-|-78
abc-|-099
bcd-|-153
bcd-|-123
bcd-|-123

I need to retrieve like ,

sgm-|-numbr 
-----------
abc-|-123
bcd-|-153

ie, I need to remove the repeated ones in the first column. ie sgm shouldn’t repeat.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:34:12+00:00Added an answer on June 18, 2026 at 6:34 am

    Since you are using Oracle, then try this simplified version using a CTE:

    WITH CTE as (
      SELECT sgm, numbr, 
          rownum rn
        FROM YourTable 
        )
    
    SELECT CTE.sgm, CTE.numbr
    FROM CTE
    JOIN (
      SELECT sgm,  MIN(rownum) minrn
      FROM CTE
      GROUP BY sgm) t ON CTE.sgm = t.sgm AND CTE.rn = t.minrn  
    

    http://sqlfiddle.com/#!4/8d6fb/10

    You can replace your query in the CTE above.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this sql query select * from table where name like ? but
I have an sql query like this: SELECT IF( (SELECT COUNT(*) FROM `test_table2` WHERE
Hi guys I have an SQL query like this: SELECT * FROM PEOPLE P
In T-SQL you could have a query like: SELECT * FROM Users WHERE User_Rights
I have a SQL query like SELECT column1,column2 FROM table1 WHERE column1 IN('q1','q2','q3') The
I have a SQL query SELECT * FROM table WHERE column LIKE '%pdd%' .
I have sql query like this: select a.x, a.y, sum(a.foo) as foo_sum from a
I have an SQL query like: SELECT blah FROM table WHERE field1 % functCall(otherField1,
I have a SQL query like this : SELECT myXmlField.value('(./row/@myAttribute)[1]', 'nVarchar(max)') as myAttribute FROM
I have SQL query like SELECT *, dbo.func(@param1, a.point) as fValue FROM dbo.table AS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.