Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #10378

Re: sql order but move some rows bottom

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news1.as3257.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Date Sun, 04 Aug 2013 15:13:38 +0200
From Luuk <luuk@invalid.lan>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7
MIME-Version 1.0
Newsgroups comp.lang.php, alt.php
Subject Re: sql order but move some rows bottom
References <1qthmi1tu68bo$.9vs28kns3wda.dlg@40tude.net> <b14vca-jku.ln1@luuk.invalid.lan> <13413lih7j7xy.ntybohdhh9wy.dlg@40tude.net> <frnvca-j63.ln1@luuk.invalid.lan> <19m253q4wpnqg.3aexf4o8h0ae$.dlg@40tude.net>
In-Reply-To <19m253q4wpnqg.3aexf4o8h0ae$.dlg@40tude.net>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Message-ID <1l02da-q4u.ln1@luuk.invalid.lan> (permalink)
Lines 86
NNTP-Posting-Host 2001:980:9089:1:a045:606d:9ce3:46eb
X-Trace 1375622101 news.xs4all.nl 15933 [2001:980:9089:1:a045:606d:9ce3:46eb]:50665
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.php:10378

Cross-posted to 2 groups.

Show key headers only | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

sql order but move some rows bottom nawfer <novalidsforspam@alt.al> - 2013-08-03 12:44 +0200
  Re: sql order but move some rows bottom Luuk <luuk@invalid.lan> - 2013-08-03 12:53 +0200
    Re: sql order but move some rows bottom nawfer <novalidsforspam@alt.al> - 2013-08-03 18:10 +0200
      Re: sql order but move some rows bottom Luuk <luuk@invalid.lan> - 2013-08-03 18:31 +0200
        Re: sql order but move some rows bottom nawfer <novalidsforspam@alt.al> - 2013-08-04 13:50 +0200
          Re: sql order but move some rows bottom Luuk <luuk@invalid.lan> - 2013-08-04 15:13 +0200
            Re: sql order but move some rows bottom anver <NOSPAMM@NO.SPAMMS> - 2013-08-04 16:42 +0200
            Re: sql order but move some rows bottom nawfer <novalidsforspam@alt.al> - 2013-08-04 16:56 +0200
              Re: sql order but move some rows bottom Luuk <luuk@invalid.lan> - 2013-08-04 19:36 +0200
                Re: sql order but move some rows bottom nawfer <novalidsforspam@alt.al> - 2013-08-04 19:52 +0200
                Re: sql order but move some rows bottom nawfer <novalidsforspam@alt.al> - 2013-08-05 14:50 +0200
            Re: sql order but move some rows bottom nawfer <novalidsforspam@alt.al> - 2013-08-04 17:49 +0200
              Re: sql order but move some rows bottom Luuk <luuk@invalid.lan> - 2013-08-04 19:37 +0200
                Re: sql order but move some rows bottom nawfer <novalidsforspam@alt.al> - 2013-08-04 19:53 +0200
                Re: sql order but move some rows bottom Luuk <luuk@invalid.lan> - 2013-08-04 20:20 +0200
                Re: sql order but move some rows bottom nawfer <novalidsforspam@alt.al> - 2013-08-05 14:57 +0200

csiph-web