Begini caranya - alias di nama kolom
select
-- etc etc
(select innerDLI.datetime_created from distribution_line_items innerDLI where innerDLI.item_number = distribution_line_items.item_number order by innerDLI.datetime_created asc limit 1) as Origination,
-- etc etc
from distribution_stop_information
-- etc etc
Begini cara meletakkannya di mana, alias di gabung
select
-- etc etc
Origination.datetime_created
-- etc etc
from distribution_stop_information
left join distribution_line_items AS Origination ON Origination.item_number = distribution_line_items.item_number
where Origination.datetime_created > to_date(?, 'YYYY-MM-DD') - interval '180 days'
-- etc etc
Tidak ada yang lebih baik daripada solusi yang Anda posting (pengoptimal sql harus menghasilkan paket yang sama) tetapi "menggunakan alias di klausa where"