我有一张像
| id | user | bottle | count |
| 1 | foo | beer | 2 |
| 2 | bar | beer | 5 |
| 3 | som1 | beer | 6 |
| 4 | som2 | beer | 4 |
| 5 | som1 | wine | 1 |
等等
如何获得每个组(啤酒、葡萄酒等)STDDEV()
的价值MIN()
和MAX()
价值?
即我怎么得到count
| bottle | stddev |
| beer |stddev of 2 and 4|
?
另外,我怎样才能获得像上面这样的查询返回的总行数?
到目前为止我已经尝试过
SELECT STD(count) as stddev, bottle
FROM drinks WHERE count < (
SELECT MAX(count) FROM drinks)
AND count > (
SELECT MIN(count) FROM drinks)
GROUP BY bottle;
但这适用于MAX()
整个桌子,而不仅仅是
GROUP BY