Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select point_hash,
- case when s1.parent_id != -1 then
- COALESCE((
- select raw_product_receipt.price_for_unit from receipt
- inner join raw_product_receipt on receipt_id=receipt.id
- where storehouse=(select name from storehouse as s2 where s2.id=s1.parent_id) and price_id=$1
- and price_for_unit<>0
- order by receipt.date desc
- limit 1
- ), 0)
- else
- COALESCE((
- select raw_product_receipt.price_for_unit from receipt
- inner join raw_product_receipt on receipt_id=receipt.id
- where storehouse=s1.name and price_id=$1 and price_for_unit<>0
- order by receipt.date desc
- limit 1
- ), 0)
- end
- from storehouse as s1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement