Reputation: 53
I have a table that contains the following data:
- DATEURM IDV UNID
- 2013-02-02 15259 W0L0TGF0572
- 2013-02-02 15259 W0L0TGF0572
- 2013-02-02 15674 ZFA18503158
- 2013-02-02 16157 ZFA18503158
- 2013-02-02 16157 ZFA18503158
- ...
and i use this query to select data from it:
SELECT * FROM TBL order_date WHERE DATEURM BETWEEN DATE 'today'+10 AND DATE 'today'+40 order by DATEURM asc ROWS 50
What I would like is to not get duplicate rows of the UNID column and the result be something like:
- DATEURM IDV UNID
- 2013-02-02 15259 W0L0TGF0572
- 2013-02-02 16157 ZFA18503158
- ...
I played around with DISTINCT and GROUP BY but didn't manage to get any good result after a few hours :(
Upvotes: 1
Views: 1333
Reputation: 17203
From your comment, you say now you want one row per unid and you don't mind which other values you get, so try this:
SELECT unid, min(dateurm) dateurm, min(idv) idv
FROM order_date
WHERE DATEURM BETWEEN current_date + 10 AND current_date + 40
group by unid
order by 2
over the same data I get:
UNID DATEURM IDV
=========== ========== ============
W0L0TGF0572 2013-02-02 15259
ZFA18503158 2013-02-02 15674
SQL>
Upvotes: 1