GroupId GeneralId name
3 10000 aaaaa
3 10000 bbbbb
3 10000 ccccc
3 10000 ddddd
2 50000 eeeee
2 50000 fffff
2 50000 ggggg
2 50000 hhhhh
1 10000 aaaaa
1 10000 bbbbb
1 10000 ccccc
1 10000 ddddd
I want general id's max GroupId
Expected output is
GroupId
3
2
I tried below queries, but i did not get output
1. select MAX(GroupId) from tbl where GeneralId in ('3','2') Group by GroupId
2. select GroupId from tbl where GeneralId in ('3','2') Group by GroupId having GroupId=MAX(GroupId)
Please tell me the query.
Sorry, the query what i put above was not correcr,i tried
1. select MAX(GroupId) from tbl where GeneralId in ('50000','10000') Group by GroupId
2. select GroupId from tbl where GeneralId in ('50000','10000') Group by GroupId having GroupId=MAX(GroupId)
but i got output as below
GroupID
1
2
3