Sorting table with query
I want to sort this table, order by RESULT. but, the result of RESULT doesn't stored in database. What can i do? Thanks for your help.
data "Title & 1st number" is stored on table "table1".
data "2nd number" is stored on table "table2", but i just want to take one number.
data "result" does'nt stored on any table.
Title | 1st number | 2nd number | substraction | result
A | 80 | 65 | 80 - 65 | 15
B | 78 | 43 | 78 - 65 | 35
C | 100 | 95 | 100 - 65 | 5
I want to sort it by result. What should I use (query)? Thanks for your help.
Try this query
SELECT tbl1.title,tbl1.num1,tbl2.num2, CONCAT(tbl1.num1 , "-", tbl2.num2),(tbl1.num1 - tbl2.num2) as result FROM tbl1,tbl2 ORDER BY result
below is your correct solution to sorting in result column
SELECT (tbl1.num1 - tbl2.num2) as result,tbl1.id from table1 as tbl1,table1 as tbl2 where tbl1.id=tbl2.id ORDER BY result Desc
let me know if i can help you more..