Note that there are some explanatory texts on larger screens.

plurals
  1. PORDBMS - SQL Max Value of a column based upon another column's uniqueness
    primarykey
    data
    text
    <p>This is really difficult question to ask. So here goes. The following sql:</p> <pre><code>select * from Survey_Answers where QuestionID='50a350a5-9f53-4f1a-83b8-485de45ac9a9' order by MaxRating </code></pre> <p>Generates the following:</p> <pre><code>QuestionID Answer Value MaxRating MinRating -------------------------------------------------------------------------- 50a350a5-9f53-4f1a-83b8-485de45ac9a9 anywhere 0 1 0 50a350a5-9f53-4f1a-83b8-485de45ac9a9 anyplace 0 2 0 50a350a5-9f53-4f1a-83b8-485de45ac9a9 test 9 2 0 50a350a5-9f53-4f1a-83b8-485de45ac9a9 love 10 3 0 50a350a5-9f53-4f1a-83b8-485de45ac9a9 no one 10 4 0 50a350a5-9f53-4f1a-83b8-485de45ac9a9 feel this way 0 5 0 (6 row(s) affected) </code></pre> <p>In the MaxRating Column there are two "2"s. I would like the max value of those two columns. So for instance if there was three 1s and two 2s and five 4s, I would like the max value of the "value" column based upon distinct maxrating columns.</p> <p>I hope this make sense so instead of the above the result should be:</p> <pre><code>QuestionID Answer Value MaxRating MinRating -------------------------------------------------------------------------- 50a350a5-9f53-4f1a-83b8-485de45ac9a9 anywhere 0 1 0 50a350a5-9f53-4f1a-83b8-485de45ac9a9 test 9 2 0 50a350a5-9f53-4f1a-83b8-485de45ac9a9 love 10 3 0 50a350a5-9f53-4f1a-83b8-485de45ac9a9 no one 10 4 0 50a350a5-9f53-4f1a-83b8-485de45ac9a9 feel this way 0 5 0 </code></pre> <p>The 9 is the max of column "Value" based upon the Maxrating column with data of "2"</p> <p>This is so difficult to explain, so I hope someone understands this. Any help is gladly appreciated. Any help in re-wording this would be great. Thanks.</p>
    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.
 

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