Nati323 Posted June 9, 2015 Share Posted June 9, 2015 (edited) hey , suppose i have the next table: ---A-------B--- 1 2 2 3 now, i need to know how many rows there is from each value, for example the result should be: A - [1] - 1A - [2] - 1B - [2] - 1B - [3] - 1 how can i do that? EDIT: I know which values will be in each culomn Edited June 9, 2015 by Nati323 Link to comment Share on other sites More sharing options...
justsomeguy Posted June 9, 2015 Share Posted June 9, 2015 You would use count, and 2 queries (one per column).SELECT A, COUNT(A) FROM table GROUP BY A Link to comment Share on other sites More sharing options...
Nati323 Posted June 9, 2015 Author Share Posted June 9, 2015 thanks, its not possible to do this in one query? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 9, 2015 Share Posted June 9, 2015 Not that I'm aware of. You could write a stored procedure to do it, but that's still going to use multiple queries. Link to comment Share on other sites More sharing options...
Nati323 Posted June 10, 2015 Author Share Posted June 10, 2015 ok, tanks anyway. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now