How can I do the following please?

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
PIVOTtable operator to do transform the rows of these course’s grades into column, like so:SQL Fiddle Demo
This will give you:
Note that: I used the ranking function
ROW_NUMBER()withPARTITION BY Courseto partition them into four grades. So that you could then group them into these four groups.If you need to this dynamically, in case there was unknown number of grades. You can use dynamic SQL in this case to generate the list of grades dynamically like so:
Dynamic SQL Fiddle Demo