we have table as below :
user point
+-------+------+
| user1 | 6080 | // user1 has this value
+-------+------+
| user1 | 5300 |
+-------+------+
| user2 | 6080 | // user2 has this value
+-------+------+
| user3 | 6080 | // user3 has this value
+-------+------+
| user3 | 5300 |
+-------+------+
| user1 | 3520 |
+-------+------+
| user2 | 5300 |
+-------+------+
| user3 | 9800 |
i want to get the max similar value that all users have at least one of that
in this sample there are two value that all users have. 6080 and 5300
result should be 6080
how can i do that ?
Would look like this. You need to limit the results to 1, so for example for mysql you should use limit 1 at the end or for mssql select top 1 point .. etc etc.
select point
from user
group by point
having count(*)=(select count(distinct user) from user)
order by point desc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With