Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 1. select last 10 record and sort.
- * 2. calc (`rowsA` + `rowsB`) / `rowsC`.
- * 3. use Sub-Query.
- */
- SELECT `record_time`, `tmp` FROM (
- SELECT
- `record_time`,
- round(((`rowsA` + `rowsB`) / (SELECT rowsC FROM tableB WHERE bid = '1') * 100), 2) AS 'tmp'
- FROM tableA ORDER BY `record_time` DESC LIMIT 10
- ) AS `lab_last_10_sort` ORDER BY `record_time` ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement