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

Discussione: errore sum mysql

  1. #1
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427

    errore sum mysql

    codice:
    SQL1="SELECT Sum(feedback.feed_value) AS rates FROM feedback" 
    
    Set rec = Server.CreateObject("ADODB.Recordset")
    rec.open SQL1, conn
    if rec.eof then
    
    response.write "no record"
    
    else
    
    response.write rec("rate")
    end if
    Dire impazzire è poco...
    questa query , funziona con phpmyadmin e invece ritorna "no record " dalla pagina asp...

    feed_value è campo numerico e credetemi i dati ci sono...

    tanto che la query su phpmyadmin ritorna (6)


  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    E' successo anche a me...:

    codice:
    SQL1 = "SELECT REPLACE(FORMAT(SUM(feedback.feed_value),0), ',', '') AS rates FROM feedback"
    rec.open SQL1, conn
            if not rec.EOF then
                rates = rec("rates")
            else
                rates = 0
            end if
            set rec = nothing
            if rates &"[]" = "[]" then rates = 0
    ...
    ...
    ...
    Roby

  3. #3
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427
    grazie roby,
    ma perchè succede ?

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Credo sia un bug dell'ODBC che phpMyAdmin non utilizza.

    Roby

  5. #5
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427
    allora mi trovo in difficoltà:


    codice:
    SQL1_test="SELECT Sum(feedback.feed_value) AS subtotale, "&_
    "(SELECT COUNT(*)  from feedback where id_user = "&id_utente&"  and risposta1=true) AS tot_rec, "&_
    "(SELECT COUNT(*) from feedback where id_user = "&id_utente&" and risposta1=true)  AS rate, "&_
    "(SELECT sum(feed_value) from feedback where id_user = "&id_utente&" and risposta1=true) AS tot_punti FROM feedback WHERE (((feedback.id_user)="&id_utente&") "

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Che c'è?
    Tiro a indovinare?

    Roby

  7. #7
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427
    SQL1_test="SELECT Sum(feedback.feed_value) AS subtotale,....

    il problema è proprio quello del sum...
    che in questa query si ripete più volte..

    ho cercato di sostituire la sintassi che mi hai proposto ma va in errore...

  8. #8
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    L'avrai scritta male...

    Roby

  9. #9
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427
    come hai scritto tu , trasforma il valore in stringa...
    codice:
    SELECT CAST(SUM(VOTO) AS SIGNED )
    ciao.

  10. #10
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Prova anche la FORMAT

    Roby

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 © 2026 vBulletin Solutions, Inc. All rights reserved.