我在过滤查询中的重复值时遇到问题。这是我的查询
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');
这些是我遇到问题的部分:
(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);
这些部分总是得到多条记录,我只想得到1条序列号最低的记录,所以这就是我所做的:
(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);
但是我总是收到一个错误说缺少括号,但是当我删除订单时,它工作正常。我应该怎么做才能让我的查询正确运行?