![]() |
| |||
| "Marty Meyers" <martym@execpc.com> wrote in message news:1221g89ld0dtoab@corp.supernews.com... > if (ColA=0) > { // use Col B} > > elseif(ColA > 0 && colA < ColB) > { // use Col A > } > else > { //use ColB} SELECT ... ORDER BY CASE WHEN ColA = 0 THEN ColB WHEN ColA > 0 AND ColA < ColB THEN ColA ELSE ColB END It's based on the fact that the arguments to ORDER BY are expressions, not simply column names. You can use things like CASE and IF() to make interesting, complex expressions. Read more about these functions here: http://dev.mysql.com/doc/refman/5.0/...functions.html > The MsSQL manual doesn't seem to cover this, nor does the two beginner > books I have. A pointer to a reference where I can learn about advanced > "Order by" would be great It's not much, but here's an article I found through Google: http://www.sqlteam.com/item.asp?ItemID=2209 It's written for Microsoft SQL Server users, but it mostly applies to MySQL as well. Regards, Bill K. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |