Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select tr.rate_sale, tr.rate_buy, to_char(tr.buy_start_time, 'DD.MM.YYYY hh:mm' ) as buy_start_time,
- to_char(tr.sale_start_time, 'DD.MM.YYYY hh:mm' ) as sale_start_time
- from t_subject ts1
- inner join t_rate tr on tr.subject_id = ts1.subject_id
- inner join t_currency tc on tc.currency_id = tr.currency
- where ts1.subject_id = 1713 and tc.brief = 'USD'
- and tr.active = true
- and tr.buy_start_time <= (now())
- and buy_start_time = (select r2.buy_start_time from t_rate r2 where r2.active = true and r2.subject_id = 1713 and r2.currency = tc.currency_id order by r2.buy_start_time desc limit 1)
- and tr.sale_start_time <= (now())
- and tr.sale_start_time = (select r3.sale_start_time from t_rate r3 where r3.active = true and r3.subject_id = 1713 and r3.currency = tc.currency_id order by r3.sale_start_time desc limit 1)
- and tr.rate_type = 'manual' limit 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement