I am using max in following way at various places but here i am getting error that single single-row subquery returns more than one row. I made correction in following query by taking max as following max(c.company_name) ,that solves my problem...but that is not the requirement. Can any one help in this case
Please let me know asap to resolve this problem
select max ((select c.COMPANY_NAME
from companies c
where c.COMPANIES_ID in (
select distinct case when (select ta.transport_advis_id from transport_advis ta where ta.PACKING_NOTE_DETAILS_ID = pnd.PACKING_NOTE_DETAILS_ID and ta.deleted='N') is null
Then
Case
When pn.STATUS_CODES_ID = 50717
then
pn.companies_id
when pn.STATUS_CODES_ID = 50716
Then
pn.companies_id
Else
NULL
End
Else
to_number((select ta.carrier from transport_advis ta where ta.PACKING_NOTE_DETAILS_ID = pnd.PACKING_NOTE_DETAILS_ID and ta.deleted='N'))
End Carrier
from
packing_notes pn,
packing_note_details pnd,
order_details od
where pn.packing_notes_id = pnd.packing_notes_id
And pnd.order_details_id = od.order_details_id
and od.orders_id = 288541300)) from companies;