Hi,
SELECT * FROM TheAssignmentPuzzle
| ID | Val |
| 1 | 10 |
| 2 | 30 |
| 3 | 29 |
Declare @id int
Select @id=max(vals) from TheAssignmentPuzzle
group by id
select @id
It returns 29, but in the table max value is 30.
| ID | Val |
| 1 | 10 |
| 2 | 30 |
| 3 | 29 |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Suraj KumarRank #353 · 7.1K reputationPosted Sep 26, 2018, 10:06 PM EDT
Laxmidhar SahooRank #383 · 6.6K reputationPosted Sep 29, 2018, 5:03 AM EDT
Jayesh VaghasiyaRank #9,790 · 202 reputationPosted Oct 26, 2018, 3:34 AM EDT
Mageshwaran RRank #411 · 6.1K reputationPosted Nov 13, 2019, 12:42 AM EST
Jaimin ShethiyaRank #177 · 13.7K reputationPosted Nov 13, 2019, 6:44 PM EST
can you please try below script and let me know it's working or not.
You have wrong write the group by statement.
group by id means they have grouping the id wise and shows the max id is 3 and value is 29 so result is showing 29.
Thanks.