MySQL as count group by?
-
select count(1), domain_id as "row_count", "domain_id" from rtr_traffic_mo group by domain_id; I gave the above query in mysql but instead of two columns its showing 3 columns. I basically want count(1) to be represented as row_count and domain_id as domain_id. It would be of great help if you could tell me what 1 is for in count(1) and what is the significance of 'group by' here. What if I dont give that.
-
Answer:
By using 'group by domain_id;' you are instructing to show each domain_id only once in the result set. and in the 'select' clause you may perform certain functions on the data in different fields of the records having same domain_id. If you want to get the number of occurrences of each domain_id. you may use following query. select count(domain_id) as row_count, domain_id from rtr_traffic_mo group by domain_id;
Anirudh agarwal at Yahoo! Answers Visit the source
Related Q & A:
- Can I estimate the row count of a large mysql table using the disk space?Best solution by Database Administrators
- How do you find a Yahoo group when you know the exact name of the group?Best solution by Yahoo! Answers
- If I start a group, can I email to all members of my group or notify them there is a new blog?Best solution by Yahoo! Answers
- How to merge one yahoo group with another yahoo group?Best solution by Yahoo! Answers
- I have create yahoo Profile to join a yahoo group, but i unable to join any group, How to Join a group.Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.