Jump to content

Grouping and summery


mpower

Recommended Posts

Hi,
I'm not that used to MySQL, yet. I wonder if it's possible to do the following grouping with summery on a record set?
Tha records set looks as follows:

- type
- topic
- description
- time

Example of data:

Admin Email Email to customer A 0,25
Admin Email Email to customer B 0,25
Dev      DB   Customer A DB   1,25
Dev      DB   Customer B DB   0,75
Dev      DB   Customer A DB   0,50
Admin Email Email to customer B    0,25

I've done the following:

[code]
SELECT
type,
topic,
description
FROM
stamps
GROUP BY
type,
topic
[/code]

This gives me:

Admin Email Email to customer A 0,25
Admin Email Email to customer B 0,25
Dev      DB   Customer A DB   1,25
Dev      DB   Customer B DB   0,75

How I want it to look like is as follows:

Admin Email Email to customer A 0,25
Admin Email Email to customer B 0,50
                      Email to customer B
Dev      DB      Customer A DB   1,75
                      Customer A DB
Dev      DB      Customer B DB   0,75

Is this possible in any way? Would be very pleased for a bit of help.

Thanks in advance // Jonas
Link to comment
Share on other sites

[quote author=mpower link=topic=117722.msg480481#msg480481 date=1165500033]
No, I don't think that solves my problem. Tried it a bit and it didn't do what I wanted it to.
Please take a look at my description of the problem again.
[/quote]
I've reread the initial post several times, and I'm still not clear on what you want. Groupings are only able to be done with MySQL when you have some sort of aggregate functions going on (COUNT, SUM, AVG, etc). Otherwise, you need to handle it in PHP. You also mention summary listings, but I'm not following what your example output is trying to convey. Could you try to break it down and describe what your fields are and [b]how[/b] you want them summarized?
Link to comment
Share on other sites

When I've grouped by two, type and topic, I want the data for description to be shown for the second, thierd etc. row witch is in the group as well. I don't know if this is possible? In this case the descripton often isn't the same in each rows, as the type and topic.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.