Jump to content

Geee

Members
  • Posts

    1
  • Joined

  • Last visited

Geee's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hello I have this SQL Statement: de.SqlStatement = "SELECT A.Name, A.Catagory , COUNT(Patient_ID) AS PNO FROM PatientApplyToAssociation P INNER JOIN Association A on A.Association_ID = P.Association_ID WHERE A.Catagory='" & "health" & " '" & "' GROUP BY A.Name '" with this Exception: System.Data.SqlClient.SqlException was unhandled by user code class="16" ErrorCode=-2146232060 LineNumber=1 Message=Column 'Association.Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. I had this exception when I added the where clause, It seems that the compiler cant see the Group By Section , because of the quotation ending before it, I tried to write it like this: de.SqlStatement = "SELECT A.Name, A.Catagory , COUNT(Patient_ID) AS PNO FROM PatientApplyToAssociation P INNER JOIN Association A on A.Association_ID = P.Association_ID WHERE A.Catagory='" & "health" & "' GROUP BY A.Name '" & " '" But it was an Incorrect syntax near ' '. p.s. I selected A.Catagory because I needed it in the WHERE clause, I need the category to be "health"Any ideas ? Please Help me..Thank you
×
×
  • Create New...