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

    Problema con SQL con media matematica

    DEvo fare una media ho scritto questa sql

    codice:
    strSQL = "SELECT Avg(str_voto) As Media,str_nomegioc,str_cognomegioc,str_giocatore,str_giornata,id_calendario  FROM (tb_pagelle INNER JOIN tb_giocatori ON tb_pagelle.str_giocatore = tb_giocatori.id_giocatore) INNER JOIN tb_calendari ON tb_pagelle.str_giornata = tb_calendari.id_calendario"

    ma mi da questo errore:
    The specified field 'str_giornata' could refer to more than one table listed in the FROM clause of your SQL statement.

    /home/pagelle.asp, line 31


    come devo modificare ? :master:

  2. #2
    codice:
    "select a.campo1, a.campo2, b.campo1, b.campo2 from tabella1 a inner join tabella2 b on a.campo1 = b.campo1"
    Oppure
    codice:
    "select tabella1.campo1, tabella1.campo2, tabella2.campo1, tabella2.campo2 from tabella1 inner join tabella2 on tabella1.campo1 = tabella2.campo1"

  3. #3
    :master: :master: :master:

    codice:
    strSQL = "SELECT Avg(str_voto) As Media,tb_pagelle.str_giocatore,tb_giocatori.id_giocatore,tb_pagelle.str_giornata,tb_calendari.id_calendario FROM (tb_pagelle INNER JOIN tb_giocatori ON tb_pagelle.str_giocatore = tb_giocatori.id_giocatore) INNER JOIN tb_calendari ON tb_pagelle.str_giornata = tb_calendari.id_calendario"



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

    /home/pagelle.asp, line 31
    :master:

  4. #4
    Purtroppo, quando usi le funzioni di aggregazione in SQL, come ad esempio AVG, DISTINCT, COUNT, non puoi selezionare altri campi.

  5. #5
    e come posso fare per ovviare a questo?

  6. #6
    Con una prima query ti prendi gli altri dati e con una seconda la media.

  7. #7
    è la soluzione che avevo pensato...

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.