Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 16
  1. #1

    Select multipla ed order by

    Ciao ragazzi. Per la prima volta mi capita di dover fare una query del tipo: SELECT Campo1 FROM
    tabella, SELECT Campo2 FROM tabella2 ORDER BY Campo1 + Campo2.


    Quale sarebbe la sintassi corretta?


    grazie
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  2. #2
    non ho capito... :master: :master:

  3. #3
    Ho due tabelle:


    Utente: coi campi Nick e Crediti

    Banca: coi campi Nome e Crediti


    devo stampa tutti i Nick di Utente ordinandoli per il campo Crediti + Crediti della seconda tabella(ovviamente i crediti + crediti avviene se Nick = Nome)


    ESEMPIO PRATICO


    nella tabella uno c'è Antonio 1000, Francesco 500, Andrea 35

    nella tabella due Antonio 100, Andrea 200

    la query stamperà

    1)Antonio 1100
    2)Francesco 500
    3)Andrea 235
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  4. #4
    SELECT Nome,(Utente.Crediti + Banca.Crediti) AS Crediti FROM Utente,Banca WHERE Utente.nick = Banca.Nome

    Dovrebbe andare..

  5. #5
    dimenticavo l'ordinamento....

    SELECT Nome,(Utente.Crediti + Banca.Crediti) AS Crediti FROM Utente,Banca WHERE Utente.nick = Banca.Nome ORDER BY Crediti DESC

  6. #6
    purtroppo non solo non va, ma se un utente non c'è anche in Banca non viene stampato proprio.
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  7. #7
    cosa ti tira fuori?

  8. #8
    nella tabella utenti ho:

    Antonio 7000, Andrea 1000

    in quella banca ho:

    Antonio 100, Antonio 200, Antonio 50, Andrea 200


    MI STAMPA:

    Antonio 7000
    Antonio 7000
    Antonio 7000
    Andrea 1000
    Andrea 1000

    INVECE DOVREBBE STAMPARMI:

    Antonio 7350
    Andrea 1250
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  9. #9
    ragazzi state dimenticando la clausola Group By.


    codice:
    Select nick, (b.crediti + u.crediti) as Tot
    from banca b, utente u
    where u.nick = b.nome
    GROUP BY nick
    Order by Tot DESC

  10. #10
    Originariamente inviato da xxxAlex83xxx
    ragazzi state dimenticando la clausola Group By.


    codice:
    Select nick, (b.crediti + u.crediti) as Tot
    from banca b, utente u
    where u.nick = b.nome
    GROUP BY nick
    Order by Tot DESC
    resta il problema che non mi stampa gli altri utenti, quelli che non sono presenti in banca
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

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.