sql - MySQL GROUP BY…exclude values in other field -
i have problem mysql query statistic-page. want use query similar following retrieve rows "version" want exclude values in other field "platform" if not same value.
example values:
| platform | version | ... ---------------------- | windows | 1.0.1 | | windows | 1.0.1 | | windows | 1.0.1 | | windows | 1.0.2 | | windows | 1.0.3 | | linux | 1.0.1 | | linux | 1.0.1 | | linux | 1.0.2 | | mac | 1.0.1 | | mac | 1.0.1 | query:
select platform, version, count(*) count user group version result:
| platform | version | count | ------------------------------ | windows | 1.0.1 | 7 | | windows | 1.0.2 | 2 | | windows | 1.0.3 | 1 | i need following result:
| platform | version | count | ------------------------------ | windows | 1.0.1 | 3 | | windows | 1.0.2 | 1 | | windows | 1.0.3 | 1 | | linux | 1.0.1 | 2 | | linux | 1.0.2 | 1 | | mac | 1.0.1 | 2 | i hope can me... , sorry english.
i think need right group by clause:
select platform, version, count(*) count user group platform, version; your query not syntactically correct sql. column platform in select not in group by. database other mysql correctly return error.
Comments
Post a Comment