messer Posted June 8, 2009 Share Posted June 8, 2009 I'm new in SQL,and i don't know how to make to work this query? Any advice would help me... Thanks SELECT table1 . coloum1 , table1 . coloum2 , table1 . coloum3 , table1 . coloum4 , SUM(table1 . coloum3) , SUM(table1 . coloum4) FROM `table1` WHERE ( SUM(table1 . coloum3) >= SUM(table1 . coloum4) ) GROUP BY table1 . coloum1 Link to comment https://forums.phpfreaks.com/topic/161378-help-please-with-select/ Share on other sites More sharing options...
fenway Posted June 9, 2009 Share Posted June 9, 2009 You can't use SUM in a WHERE clause. Link to comment https://forums.phpfreaks.com/topic/161378-help-please-with-select/#findComment-852210 Share on other sites More sharing options...
messer Posted June 9, 2009 Author Share Posted June 9, 2009 My question is how to sort,to show only the results of the SUM of those two coloumn 3 and 4 ? Link to comment https://forums.phpfreaks.com/topic/161378-help-please-with-select/#findComment-852539 Share on other sites More sharing options...
Ken2k7 Posted June 11, 2009 Share Posted June 11, 2009 You mean something like this - SELECT coloum1 + coloum2 AS sum1, coloum3 + coloum4 AS sum2 FROM table1 ORDER BY sum1, sum2 DESC If not, sorry. I don't fully understand your query. Link to comment https://forums.phpfreaks.com/topic/161378-help-please-with-select/#findComment-853463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.