Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 23

Discussione: Order by cast

  1. #1

    Order by cast

    Facendo Order by cast(campo as signed) desc mi ordina bene gli interi, ma se ho 1,5 e 1,6 non li metti dal più grande a scendere. Come li ordino? Thanks

  2. #2
    hai provato con

    Order by cast(campo as decimal) desc

    ???

  3. #3
    Da' errore.

  4. #4
    i valori decimali li scrivi col punto ? tipo 1.5, 1.6 e non con la virgola...

  5. #5
    Ho provato nei 2 modi, non cambia.

  6. #6
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,922
    Originariamente inviato da poeta1978
    Ho provato nei 2 modi, non cambia.
    Strano, facendo il replace della virgola col punto deve funzionare

    codice:
    select * from tabella
    order by cast(replace(campo_valori,',','.') as decimal) desc

  7. #7
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'decimal) DESC' at line 1
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home1/site/public_html/site/classifiche.php on line 120

  8. #8

  9. #9

  10. #10
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    591
    manuale
    The CAST() and CONVERT() functions may be used to take a value of one type and produce
    a value of another type. Their syntax is:
    CAST(expression AS type)
    CONVERT(expression,type)
    CONVERT(expr USING transcoding_name)
    The type value can be one of the following:
    ² BINARY
    ² CHAR
    ² DATE
    ² DATETIME
    ² SIGNED {INTEGER}
    ² TIME
    ² UNSIGNED {INTEGER}

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.