MySqlTalk.com  

Go Back   MySqlTalk.com > MySQL > Database Design
User Name
Password
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread
Old 02-05-2005, 08:33 AM   #1
Azkaban
Senior Member
 
Join Date: Jul 2004
Posts: 167 Azkaban is on a distinguished road
Is there any way to get detailed data into an aggregate function?

When you are aggregating data, for example:

PHP Code:
SELECT name,COUNT(*)as count
FROM t1
GROUP BY name
HAVING count
>


Will give you a count of every row with the same name. But let's say you want all usernames that use the same name.

For example, if 5 users are named John Smith, and you have usernames like johnsmith,johnsmith2,js,etc. and you want a count of all names with multiple users, the above works. The record will produce

name | count
============
John Smith | 5
Jeff Green | 3

But if you want the rows transposed, is it doable? The output should look like

name | count
=============
John Smith | 5 | johnsmith,johnsmith1,js1,js2,jsmith
Jeff Green | 3 | jeffg,jeffgreen,jeffgreen2


Of course you can iterate by getting one table with the count, then going back into the table and pulling out all the usernames that matches each name, but it seems wasteful. Mysql processes the rows the first time, why not pull out all the data while there?
Azkaban is offline   Fork this post Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Corruption using navicat webie Navicat Support 1 08-19-2005 02:12 PM
Limiting Data to specific format kfschaefer Database Design 2 12-01-2004 05:05 AM
Problems Entering Data from terminal to Mysql? fvs General 2 10-01-2004 07:02 PM
Import Access, Excel and data of other formats to MySQL by Navicat NavicatGuy Articles 0 08-17-2004 01:08 AM
2 Installing MySQL Administrator Documentation 103 06-09-2004 02:53 AM



All times are GMT -4. The time now is 01:28 PM.



Powered by: vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Google
  Web http://www.mysqltalk.com
DISCLAIMERS:
1. We have no commercial interest in this site.
Banner Ads and Subscriptions will only be used to help pay for hosting and maintenance costs.
2. MySQLTalk.com is NOT affiliated with MySQL AB in any way.
3. MySQLTalk.com is NOT endorsed by MySQL AB in any way.
4. Please do not post any content that is harmful to MySQL or MySQL AB, meaning no misleading or obsolete information will be tolerated.
Well-founded constructive criticism meant to help the community is permitted.
5. This website is founded with the goal of improving the MySQL community.
We not only tolerate newbies, we encourage them.
Please do not ask newbies to "read the manual".