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 #182440 is a reply to message #182431] Sun, 04 August 2013 17:36 Go to previous messageGo to previous message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma:
Senior Member
On 04-08-2013 16:56, nawfer wrote:
> Il Sun, 04 Aug 2013 15:13:38 +0200, Luuk ha scritto:
>
> ok wonderful
> newly thanks
> how really champion (your) last finishing touch
> I assuming case where there is a row that have 100 and y
>
> ORDER BY (column2 = 100 or column3='Y') ASC, column1 ASC, column2 ASC
> 6
> 7
> 8
> 1 100
> 1 100
> 2 y
> 4 y
> 5 y
> 5 100 y
> 5 100
> 7 100
>
> .......................................................................
> 1) 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
>
> 6
> 7
> 8
> 2 y
> 4 y
> 5 y
> 1 100
> 1 100
> 5 100
> 7 100
> 5 100 y
>
> in this case row 100 y is in the 'group' of the 100 rows; set at the '100
> group's end; is possible have first? so:
> 2 y
> 4 y
> 5 y
> 5 100 y
> 1 100
> 1 100
> 5 100
> 7 100
>
>
> ........................................................................
> 2) 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
>
>
> 6
> 7
> 8
> 1 100
> 1 100
> 5 100
> 7 100
> 2 y
> 4 y
> 5 y
> 5 100 y
>
> in this case row 100 y is in the 'group' of the y rows
> set at the 'y group's end; is possible have first? so:
> 1 100
> 1 100
> 5 100
> 7 100
> 5 100 y
> 2 y
> 4 y
> 5 y
>

If you understood the example i gave you, you should be able to figure
that part out yourself!
[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: Sat Nov 30 22:56:44 GMT 2024

Total time taken to generate the page: 0.04407 seconds