SHARE
TWEET

Last 10 record and Sort (Sub-Query)

chusiang Jan 15th, 2013 37 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * 1. select last 10 record and sort.
  3.  * 2. calc (`rowsA` + `rowsB`) / `rowsC`.
  4.  * 3. use Sub-Query.
  5.  */
  6.  
  7. SELECT `record_time`, `tmp` FROM (
  8.  
  9.         SELECT
  10.         `record_time`,
  11.         round(((`rowsA` + `rowsB`) / (SELECT rowsC FROM tableB WHERE bid = '1') * 100), 2) AS 'tmp'
  12.         FROM tableA ORDER BY `record_time` DESC LIMIT 10
  13.  
  14. ) AS `lab_last_10_sort` ORDER BY `record_time` ASC;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top