| how can i return only one row of data on this query? [message #571649] |
Wed, 28 November 2012 09:01  |
 |
ricanmix79
Messages: 1 Registered: November 2012 Location: Sacramento
|
Junior Member |
|
|
work_order unitid frommi tomi frompm topm
2666054111 06-154 77.000 85.000 77.370 null
2666054111 06-154 77.000 85.000 null 85.370
2666054111 06-154 77.000 85.000 null null i used select distinct(work_order) to come up with the three different possible scenarios
the problem is that i need all this information on a single row
work_order unitid frommi tomi frompm topm
2666054111 06-154 77.000 85.000 77.370 85.370 this is a conversion for distance. when i get this to work properly, it will
generate reports on thousands of work orders with their converted distance markers.
i am stuck 
[EDITED by LF: applied [pre] tags to preserve formatting]
[Updated on: Wed, 28 November 2012 10:29] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
| Re: how can i return only one row of data on this query? [message #571657 is a reply to message #571654] |
Wed, 28 November 2012 10:33  |
 |
Littlefoot
Messages: 16997 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
An aggregate function (such as MAX) might help. Here's an example; see if you can use it and apply to your own table & data:
This is what you currently have:
SQL> select * from test;
WORK_ORDER UNITID FROMPM TOPM
---------- ---------- ---------- ----------
266 6 77,37
266 6 85,37
266 6
Now, apply MAX and see what happens:
SQL> select work_order,
2 unitid,
3 max(frompm) frompm,
4 max(topm) topm
5 from test
6 group by work_order, unitid;
WORK_ORDER UNITID FROMPM TOPM
---------- ---------- ---------- ----------
266 6 77,37 85,37
SQL>
|
|
|
|