buonasera a tutti. cerco di spiegarmi bene.
ho una tabella così composta:
codicegiocatore | codicecampo | scarto |
1770 | 36 | N
1770 | 36 | S
1770 | 36 | S
vorrei contare quanti N ci sono per ogni campo e ogni giocatore ma evidentemente con il codice sottostante sbagli qualcosa
codice:sSQL = "SELECT punteggi.codiceGiocatore, Gare.CodiceCampo, Punteggi.ScartoPunti " sSQL = sSQL & "FROM ["&percorsoserver&"].Gare INNER JOIN punteggi ON Gare.CodiceGara = punteggi.CodiceGara " sSQL = sSQL & "WHERE punteggi.ScartoPunti = 'N' " sSQL = sSQL & "ORDER BY punteggi.codiceGiocatore ASC, gare.CodiceCampo ASC " set listaGioc=FigspConn.execute (sSql) if not listaGioc.EOF then while not listaGioc.EOF 'conto quante gare il giocatore ha fatto su un campo SQL = "SELECT punteggi.codiceGiocatore, Count(Punteggi.ScartoPunti) AS conta, Gare.CodiceCampo " SQL = SQL & "FROM ["&percorsoserver&"].Gare INNER JOIN punteggi ON Gare.CodiceGara = punteggi.CodiceGara " SQL = SQL & "WHERE punteggi.codicegiocatore = '"& listaGioc("codicegiocatore") &"' " SQL = SQL & "AND Gare.CodiceCampo = "& listaGioc("codicecampo") &" " SQL = SQL & "GROUP BY punteggi.codiceGiocatore, Gare.CodiceCampo " SQL = SQL & "ORDER BY punteggi.codiceGiocatore ASC, gare.CodiceCampo ASC " Set contGare = Server.CreateObject("ADODB.Recordset") contGare.open SQL,FigspConn,3,1 response.write contGare("codicegiocatore") & " | " response.write contGare("codicecampo") & " | " response.write contGare("conta") & " <br> " response.flush listaGioc.MoveNext wend end if
mi estrae:
codicegiocatore | codicecampo | conta
1770 | 36 | 3
1770 | 36 | 3
ma dovrebbe darmi solo
1770 | 36 | 1
dove sbaglio?
Grazie

Rispondi quotando