Home » RDBMS Server » Server Administration » How to return only one row when no easy link?
How to return only one row when no easy link? [message #372531] Tue, 20 February 2001 12:41 Go to next message
Kieron Smythe
Messages: 11
Registered: March 2000
Junior Member
Hello all Oracle boffins,

I have a query:

SELECT sha.header_id,
sha.order_number,
sla.line_id,
sld.line_detail_id,
sla.line_number,
sha.customer_id,
we.wip_entity_name,
sld.quantity,
Sld.schedule_date
FROM So_headers sha,
Mtl_system_items msi,
Wip_so_allocations wsa,
Wip_entities we,
So_line_details sld,
wip_discrete_jobs wdj,
So_lines sla
WHERE Sla.s27 = 21
AND sla.line_id = wsa.demand_source_line
AND wsa.wip_entity_id = we.wip_entity_id
AND sla.inventory_item_id = msi.inventory_item_id
AND sla.warehouse_id = msi.organization_id
AND sla.header_id = sha. header_id
AND sla.line_id = sld.line_id
AND sld.quantity = wsa.quantity_allocated
AND wdj.wip_entity_id = we.wip_entity_id
/

It returns:

HEADER_ID ORDER_NUMBER LINE_ID LINE_DETAIL_ID LINE_NUMBER CUSTOMER_ID QUANTITY SCHEDULE_
--------- ------------ --------- -------------- ----------- ----------- --------- ---------

1441 213 1542 1359 2 4308 6 02-FEB-01
1441 213 1540 1356 1 4308 5 02-FEB-01
1441 213 1540 1358 1 4308 5 02-FEB-01
1441 213 1540 1356 1 4308 5 02-FEB-01
1441 213 1540 1358 1 4308 5 02-FEB-01

Now, I know why it returns duplicates. There is no link between the detail_lines table and the wip_entities table.

How do I restrict it to only return:

HEADER_ID ORDER_NUMBER LINE_ID LINE_DETAIL_ID LINE_NUMBER CUSTOMER_ID QUANTITY SCHEDULE_
--------- ------------ --------- -------------- ----------- ----------- --------- ---------
1441 213 1542 1359 2 4308 6 02-FEB-01
1441 213 1540 1356 1 4308 5 02-FEB-01
1441 213 1540 1358 1 4308 5 02-FEB-01

All help appreciated!

Regards,
Kieron
Re: How to return only one row when no easy link? [message #372535 is a reply to message #372531] Tue, 20 February 2001 19:43 Go to previous messageGo to next message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
select distinct sha.header_id,
sha.order_number ...
Re: How to return only one row when no easy link? [message #372571 is a reply to message #372531] Fri, 23 February 2001 09:57 Go to previous message
Cool
Messages: 2
Registered: February 2001
Junior Member
use select distinct
Previous Topic: IF .... THEN
Next Topic: concatenate text in the same field
Goto Forum:
  


Current Time: Sat May 18 06:11:40 CDT 2024