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

  • SEARCH
  • Home
  • 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 9152093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:57:34+00:00 2026-06-17T11:57:34+00:00

I’m having a problems filtering the duplicate values from my query. This is my

  • 0

I’m having a problems filtering the duplicate values from my query. This is my query

SELECT  cid.IDS_NO,cid.SUB_TITLE,cid.E_SUB_NAME, (cid.SUB_TITLE || ' '|| cid.E_SUB_NAME),
(SELECT(INST_BLK_HSE || ' ' || (SELECT E_STREET_NAME FROM street_table where street_code = d.INST_ST_CODE)) 
FROM del d where d.IDS_NO = cid.IDS_NO and ROWNUM = 1), 
(SELECT INST_ST_LEVEL || '-' || INST_STUNIT FROM detail d where d.IDS_NO = cid.IDS_NO and rownum = 1),
('COUNTRY' ||' ' || pl_post),pl_post 
FROM SUBSCRIBER cid where pl_postal_district = 15 and rownum < 3001 
and hi_property_type IN ('CONDO','COMMERCIAL BUILDING');

These are the parts I’m having problems with:

(SELECT(INST_BLK_HSE || ' ' || (SELECT E_STREET_NAME FROM street_table where street_code = d.INST_ST_CODE)) 
FROM del d where d.IDS_NO = cid.IDS_NO and ROWNUM = 1), 
(SELECT INST_ST_LEVEL || '-' || INST_STUNIT FROM detail d where d.IDS_NO = cid.IDS_NO and rownum = 1);

These parts always get multiple records, and I want to get only 1 record with the lowest sequence number, So here’s what I did:

(SELECT(INST_BLK_HSE || ' ' || (SELECT E_STREET_NAME FROM street_table where street_code = d.INST_ST_CODE)) 
FROM del d where d.IDS_NO = cid.IDS_NO and ROWNUM = 1 ORDER BY d.SEQ_NO DESC), 
(SELECT INST_ST_LEVEL || '-' || INST_STUNIT FROM detail d where d.IDS_NO = cid.IDS_NO and rownum = 1 ORDER BY d.SEQ_NO DESC);

But I always get an error saying missing parenthesis, but when I remove the order by, it works fine. What should I do to get my query running correctly?

  • 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-17T11:57:35+00:00Added an answer on June 17, 2026 at 11:57 am

    Formatting your query to make it easier to read goes a long way to begin with.

    But you also have a rather tricky problem, since you ..

    want to get only 1 record with the lowest sequence number.

    Should work like this:

    SELECT s.ids_no
          ,s.sub_title
          ,s.e_sub_name
          ,(s.sub_title || ' '|| s.e_sub_name) AS title_sub_name
          ,d.some_col_name
          ,t.inst_name
          ,('COUNTRY' ||' ' || s.pl_post) AS country_post
          ,s.pl_post
    FROM   subscriber s
    
    LEFT   JOIN (
       SELECT d.ids_no
             ,(d.inst_blk_hse || ' ' || st.e_street_name) AS some_col_name
             ,ROW_NUMBER() OVER (PARTITION BY d.ids_no ORDER BY d.seq_no) AS rn
       FROM   del d
       LEFT   JOIN e_street_name st ON st.street_code = d.inst_st_code
       ) d ON d.ids_no = s.ids_no AND d.rn = 1
    
    LEFT   JOIN (
       SELECT ids_no
             ,(inst_st_level || '-' || inst_stunit)  AS inst_name
             ,ROW_NUMBER() OVER (PARTITION BY d.ids_no ORDER BY d.seq_no) AS rn
       FROM   detail         
       ) t ON t.ids_no = s.ids_no AND t.rn = 1
    
    
    WHERE  s.pl_postal_district = 15
    AND    s.rownum < 3001 
    AND    s.hi_property_type IN ('CONDO','COMMERCIAL BUILDING');
    

    More details on how the subqueries work under this related question:
    Select first row in each GROUP BY group?

    The core features is ROW_NUMBER() to get the record with the lowest sequence number.
    I rewrote your correlated subqueries, because they generally suck performance-wise. They are also hard to read.
    I use LEFT JOIN, so you still get a row in case the subquery shouldn’t find anything to match.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build

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.