SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Nov 30, 2009, 09:29 #1
- Join Date
- Aug 2009
- Posts
- 22
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Order by average of two columns MYSQL???
Hi Guys,
Wondering if anybody has any tips on ordering a select by the average of two columns in mysql
For example..
Price_min Price_max
12000 14000
In my DB I insert price_min and price_max, then on my php results page I want to sort and display my results by average price.
Help very much appreciated.
Thanks guys
Stuart
-
Nov 30, 2009, 10:08 #2
- Join Date
- Jan 2004
- Location
- Uppsala, sverige
- Posts
- 700
- Mentioned
- 2 Post(s)
- Tagged
- 1 Thread(s)
Code:order by (price_min + price_max)/2
-
Nov 30, 2009, 10:09 #3
- Join Date
- Jun 2007
- Location
- North Yorkshire, UK
- Posts
- 483
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I assume you just want ((price_max + price_min) / 2). Just use that in you order by.
Bookmarks