The subquery is uncorrelated, so you can simply make it a derived table (moving it to the FORM
clause) or make it a CTE:
-- derived table
SELECT il.*, q.qty_in
FROM item_ledger AS il
CROSS JOIN
(SELECT SUM(qty) AS qty_in
FROM item_ledger
WHERE from_item_ledger_id = '5') AS q
WHERE il.to_id = '7'
AND q.qty_in < il.intransit_qty ;
-- common table expression
WITH q AS
(SELECT SUM(qty) AS qty_in
FROM item_ledger
WHERE from_item_ledger_id = '5')
SELECT il.*, q.qty_in
FROM item_ledger AS il
CROSS JOIN q
WHERE il.to_id = '7'
AND q.qty_in < il.intransit_qty ;
You could also use an inline subquery or a LATERAL
join (available in 9.3+ versions) but those solutions would be more useful if the subquery were correlated.