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?