Re: [PHP-DB] ? Sort by a summation of columns ? From: Doug Semig (dougslist <email protected>)
Date: 11/25/00

You can try your own suggestion, but it won't work.

How about "SELECT v1+v2+v3+v4+v5 AS sumofv FROM ... ORDER BY sumofv"?

By the way, pretend that I wrote about two or three paragraphs about how
you should make absolutely positive that your table should be designed that
way because it's usually not very relational-like to store arrays that way.

Doug

At 06:43 AM 11/25/00 -0500, Noah Spitzer-Williams wrote:
>I have a database setup as follows:
>
>some fields... | v1 | v2 | v3 | v4 | v5
>some fields... | v1 | v2 | v3 | v4 | v5
>some fields... | v1 | v2 | v3 | v4 | v5
>
>
>how can i retrieve a list of these rows sorted by the sum of v1 + v2 + v3 +
>v4 + v5?
>
>for instance, can i do like : ORDER BY sum(v1,v2,v3,v4,v5)?
>
>- Noah
>
>-- Thanks!
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>