Visualizzazione dei risultati da 1 a 9 su 9
  1. #1

    Syntax error in GROUP BY clause

    Come posso cambiare una SQL del tipo

    codice:
    strSQL="SELECT * from products where new=true AND tip_UK<>'RFID' AND online=true ORDER BY model ASC"
    in una che mi raggruppi per tip_UK

    codice:
    strSQL="SELECT * from products where new=true AND tip_UK<>'RFID' AND online=true GROUP BY tip_UK ASC"
    mi da errore:
    Syntax error in GROUP BY clause.
    /wireless/uk/news.asp, line 125

    devo indicare i campi che recupero invece di * ?

    codice:
    <% 
    Set objConn = Server.CreateObject("ADODB.Connection") 
    set rs=server.CreateObject("ADODB.recordset")
    objConn.Open strCon
    strSQL="SELECT * from products where new=true AND tip_UK<>'RFID' AND online=true GROUP BY tip_UK ASC" 
    rs.Open strSQL, objConn,3,3
    	
    recordsperpage=5
    rs.pagesize=recordsperpage
    Pages=request.querystring("pagina")
    if (len (Pages)>0 and isnumeric(Pages)) then
    Pages=clng(Pages)
    else
    Pages=1
    end if
    %>
    Grazie

  2. #2
    hai messo un ASC dopo la GROUP BY...

  3. #3
    sì ma ora mi dice

    Cannot group on fields selected with '*'.

  4. #4
    giusto. elenca i campi

  5. #5
    nulla adesso l'errore è diverso

    You tried to execute a query that does not include the specified expression 'id' as part of an aggregate function.

    codice:
    <% 
    Set objConn = Server.CreateObject("ADODB.Connection") 
    set rs=server.CreateObject("ADODB.recordset")
    objConn.Open strCon
    strSQL="SELECT id,model,tip_uk,modulation,titolo_UK,comp,descrizione_UK from products where new=true AND tip_UK<>'RFID' AND online=true GROUP BY tip_UK" 
    rs.Open strSQL, objConn,3,3
    	
    recordsperpage=5
    rs.pagesize=recordsperpage
    Pages=request.querystring("pagina")
    if (len (Pages)>0 and isnumeric(Pages)) then
    Pages=clng(Pages)
    else
    Pages=1
    end if
    %>

  6. #6
    nella group by vanno elencati tutti i campi... usi access?

  7. #7


    codice:
    strSQL="SELECT id,model,tip_uk,modulation,titolo_UK,comp,descrizione_UK,code,new from products where new=true AND tip_UK<>'RFID' AND online=true GROUP BY tip_UK"
    specified expression 'id' as part of an aggregate function.

  8. #8
    ti conviene allora progettare la query con access, cosi' vedi bene i meccanismi....

  9. #9
    a saperlo fare....

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.