mardi 4 août 2015

Selecting Multiple ID's in one Select

I have a Database with entries that have to be grouped togethe

id | Name    | Surname | Time
1  | Michael | Kane    | 3
2  | Torben  | Dane    | 4
3  | Dinge   | Chain   | 5
4  | Django  | Fain    | 5
5  | Juliett | Bravo   | 6
6  | Django  | Fain    | 7
7  | Django  | Fain    | 3
8  | Django  | Fain    | 4
9  | Dinge   | Chain   | 4
10 | Torben  | Dane    | 4

Now I want to group the items while maintaing all Id's. I'm comming close with the following query but I am lossing my ids

SELECT id, Name, Surname, sum(Time) from Names group by(Name)

The Result of the Query is

 id | Name    | Surname | Time 
 9  | Dinge   | Chain   | 9
 8  | Django  | Fain    | 19
 5  | Juliett | Bravo   | 6
 1  | Michael | Kane    | 3
 10 | Torben  | Dane    | 8

while I would need all ids like this

 ids    | Name    | Surname | Time 
 3,9    | Dinge   | Chain   | 9
 4,6,78 | Django  | Fain    | 19
 5      | Juliett | Bravo   | 6
 1      | Michael | Kane    | 3
 2,10   | Torben  | Dane    | 8

How can i accomplish this?

Aucun commentaire:

Enregistrer un commentaire