Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Syntax to get AGPA
    primarykey
    data
    text
    <p>Hi I have three tables as the following</p> <p><img src="https://i.stack.imgur.com/GZV5A.jpg" alt="enter image description here"></p> <p>I want to get the AGPA for the courses that the user passed</p> <p><img src="https://i.stack.imgur.com/p10XF.png" alt="enter image description here"></p> <p>I used this SQL syntax</p> <pre><code>string queryString = "select R.mark, c.NumberOfCredits from Courses c, RegisteredIn R where R.CourseId=c.id and R.StudentId=StudentId and R.mark &gt; 60 R.mark themark,c.NumberOfCredits credit select (sum(themark*credit)/sum(credit))*0.04 AGPA "; </code></pre> <p>and I did this to print out the results</p> <pre><code>using (SqlConnection connection = new SqlConnection(connectionString)){ SqlCommand command = new SqlCommand(queryString, connection); connection.Open(); System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader(); reader.Read(); result = string.Empty; _AGPA = reader[3].ToString(); result += string.Format("Your GPA : {0} &lt;/br&gt; ",_AGPA); Response.Write(result); reader.Close(); } </code></pre> <p>Im pretty sure the SQL syntax is wrong Im getting this error</p> <p><img src="https://i.stack.imgur.com/685RG.jpg" alt="enter image description here"></p> <p>kindly advise how to solve it and where I did a mistake.</p> <p>Thank you</p> <hr> <p>Update :</p> <p>The Data Types are as the follwoing &amp; Im using SQL Server database <img src="https://i.stack.imgur.com/7NV1A.png" alt="enter image description here"></p> <hr> <p>Update 2 :</p> <p>the StudentId is passed through the URL of the page as the following</p> <pre><code>http://localhost:3401/MobileWebWIthConnection/showagpa.aspx?StudentId=20111 </code></pre> <p>and in the code I read it </p> <pre><code>string StudentId = Request.Params["StudentId"]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload