I have a select statement that sums up points from competitions depending on which class you participated in. I have used this code.
Select Case ddBarmarkGrupp.SelectedItem.Value Case 1 : MyDataAdapter = New SqlDataAdapter("SELECT SUM(SCP_Points) AS Points, Count(SCP) AS Antal, Namn FROM resultat " & "Where SCP = 1 And SCP_Points > 1 " & "And (Grupp IN ('a')) " & "AND (Klass IN ('CW', 'CWV', '1RW', '2RW', 'BW')) " & "AND (Datum BETWEEN '2013-07-01' AND '2014-06-30') " & "GROUP BY Namn ORDER BY Points DESC, Namn ASC", MyConnection) Unfortunately hardcoded and want to select classes from a comma separated string instead, but can't get it to work
Dim MyClasses As String = "CW, CWV, 1RW, 2RW, BW" Select Case ddBarmarkGrupp.SelectedItem.Value Case 1 : MyDataAdapter = New SqlDataAdapter("SELECT SUM(SCP_Points) AS Points, Count(SCP) AS Antal, Namn FROM resultat " & "Where SCP = 1 And SCP_Points> 1 " & "And (Grupp IN ('a')) " & "AND (Klass IN ('" & MyClasses & "')) " & "AND (Datum BETWEEN '2013-07-01' AND '2014-06-30') " & "GROUP BY Namn ORDER BY Points DESC, Namn ASC", MyConnection) I've tried several different options, but can't get it to work...
Help is kindly received ![]()