-- Common feature in RDBMS, but new in MySQL 8.0, MariaDB 10.2.1 WITH low_price_history (cost, label, status) AS ( SELECT price, name, status FROM history WHERE price < 50 ORDER BY price LIMIT 20 ) SELECT label, cost, status FROM low_price_history WHERE label = 'foo';
label | cost | status |
---|---|---|
foo | 9.135420 | 3 |
foo | 9.696750 | 3 |
foo | 11.866840 | 1 |
foo | 12.970670 | 4 |
foo | 16.187910 | 2 |
foo | 16.499210 | 1 |