Visualizzazione dei risultati da 1 a 5 su 5

Discussione: SQL Query errata?

  1. #1

    SQL Query errata?

    codice:
    SELECT DISTINCT tblUtenti.ID, tblUtenti.Nome, tblUtenti.Avatar, tblUtenti.User, tblUtenti.VisiteTotali, (SELECT COUNT(ID) AS Quanti FROM tblOpere WHERE IDUtente = tblUtenti.ID) AS NumeroOpere FROM tblUtenti INNER JOIN tblOpere ON tblUtenti.ID = tblOpere.IDUtente WHERE IDCategoria = 4 OR IDCategoria = 5 OR IDCategoria = 6 OR IDCategoria = 42 OR IDCategoria = 43 OR IDCategoria = 44 ORDER BY NumeroOpere ASC
    L'errore che mi dà è:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

    [Microsoft][Driver ODBC Microsoft Access] La proposizione ORDER BY (NumeroOpere) è in conflitto con DISTINCT.

    Perchè sarebbe in conflitto? NumeroOpere non si tratta cmq di una colonna che posso utlizzare per riordinare?
    Enrico Frison
    El signore ghe da e suche a chi che no ga i porsei!

  2. #2
    Se togli la clausola "order by" la query funziona ???

  3. #3
    Si ma a me serve proprio quell'ordinamento :-(
    Non si può usare come riordinamento?
    Enrico Frison
    El signore ghe da e suche a chi che no ga i porsei!

  4. #4
    Sinceramente non sò coma mai non funzioni

    Cmq fossi in te proverei a racchiudere il tutto dentro una select es :

    select * from (select ....) order by [campo]

    Io proverei così

  5. #5
    Sei il numero uno!!!
    codice:
    SELECT * FROM 
    (SELECT DISTINCT tblUtenti.ID, tblUtenti.Nome, tblUtenti.Avatar, tblUtenti.User, 
    tblUtenti.DataUltimaModifica, tblUtenti.VisiteTotali, (SELECT COUNT(ID) AS Quanti 
    FROM tblOpere WHERE IDUtente = tblUtenti.ID) AS NumeroOpere 
    FROM tblUtenti INNER JOIN tblOpere ON tblUtenti.ID = tblOpere.IDUtente 
    WHERE IDCategoria = 4 OR IDCategoria = 5 OR IDCategoria = 6 OR IDCategoria = 42 
    OR IDCategoria = 43 OR IDCategoria = 44) AS tblUtentiOpere 
    ORDER BY NumeroOpere ASC
    Così funziona. Grazie mille
    Enrico Frison
    El signore ghe da e suche a chi che no ga i porsei!

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.