Answer the question
In order to leave comments, you need to log in
Is it possible to avoid duplicate subqueries?
There is a table that stores, for example, prices for a certain currency pair. the table looks like this:
You need to get a selection, where the first column will contain the price from a certain slice of this table, and the second column will also contain the price from this slice, but more than the first one.
That is, the request will look like this:
SELECT part_1.price, part_2.price
FROM (SELECT * FROM prices WHERE id > 1000 AND id < 2000000) AS part_1, (SELECT * FROM prices WHERE id > 1000 AND id < 2000000) AS part_2
WHERE part_1.price < part_2.price
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question