FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » sql order but move some rows bottom
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: sql order but move some rows bottom [message #182427 is a reply to message #182425] Sun, 04 August 2013 13:13 Go to previous messageGo to previous message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma:
Senior Member
On 04-08-2013 13:50, nawfer wrote:
>>>> ORDER BY (column2 = 100) ASC, column1 ASC, column2 ASC
>>>> ?
>>>
>>> but if want also to verified the 3 colum (send bottom also the y) ?
>>
>> ORDER BY (column2 = 100 or column3='Y') ASC, column1 ASC, column2 ASC
>
>
> ok very very much thanks
> Your last touch to perfection
>
> I changed to better explain the first column; instead of letters I used
> numbers
> after sort I have
>
>
> 1
> 1
> 2
> 3
> 3
> 4
> 4
> 5
> 5
> 6
> 7
> 8
> 1 100
> 1 100
> 2 y
> 4 y
> 5 y
> 5 100
> 7 100
>
> ok 100 and y are bottom; but are mixed, or better they are ordered (col 1)
> is possible have separated ? y first or after 100
>
> example y first of 100
> 6
> 7
> 8
> 2 y
> 4 y
> 5 y
> 1 100
> 1 100
> 5 100
> 7 100
>

y before 100:
ORDER BY
(CASE WHEN column2 = 100 THEN 2 ELSE 0 END + CASE WHEN column3='Y' THEN
1 ELSE 0 END) ASC, column1 ASC, column2 ASC


100 before y
ORDER BY
(CASE WHEN column2 = 100 THEN 1 ELSE 0 END + CASE WHEN column3='Y' THEN
2 ELSE 0 END) ASC, column1 ASC, column2 ASC



>
> ____
> other last two questions in sql is better use OR or || or is same?
read the manual,
i'm not interested in the answer because my opinion is that 'or' is more
readable ;)


>
> and col01 <= col02
> in this case
> col01 col02
> null or void filed <= 10
> I noticed that condition isn't verified (for me ok if so) but is always so
> for sql? col 01 if haven't a value isn't considered minor of a number?
>

http://dev.mysql.com/doc/refman/5.0/en/working-with-null.html
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: fetch items from a row
Next Topic: Validate Radio Buttons?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 03:18:18 GMT 2024

Total time taken to generate the page: 0.04671 seconds