Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

OK guys, this one is tought (for me). Here's what i'm trying to do. I have an SQL table structured like this:

+-----------+---------------+--------+--------+
| IDvoucher | IDprestazione | Number | Value  |
+-----------+---------------+--------+--------+
|       221 |            34 | 273154 |     10 |
|       222 |            35 | 273155 |     10 |
|       223 |            34 | 273161 |      5 |
|       224 |            34 | 273162 |     15 |
|       225 |            35 | 273169 |     10 |
|       226 |            34 | 273170 |     10 |
+-----------+---------------+--------+--------+

I got some IDs from a form. For each IDprestazione i have to recover the count of rows and the Numbers where Value is the same grouped for Value (so if IDprestazione is 34, n. 2 row with Value 10 in which Number is [273154] [273170] - 1 row with Value 5 in which Number is [273161] - 1 row with Value 15 in which Number is [273162]). This was the easy part.

Done this, i have to print all the recovered data without the discrimination of the IDprestazione. So if the query for the first IDprestazione had as result, 1 row with Value 10 and Number 273154 - and the second one for the second IDprestazione had as result 2 row with value 10 and number [273155] [273159], i'll have to print "n. 3 rows with value 10 and Numbers [273154] [273155] [273159]".

I've tried in many different ways but with no results, but i know you guys can do that since you helped me a lot of times. Thanks in advance.

share|improve this question
    
Don't think this is a recursive matter. You can do a SELECT DISTINCT on the IDprestazione column then do a SELECT DISTINCT on the value and then list all the Numbers per Value – Tom Kriek Oct 5 at 9:02
    
@TomKriek Possible. could you write down some code to understand better? – TheMerovingian Oct 5 at 9:08
    
Reading your post again I'm getting confused on what you are trying to do here. I'm not sure if my comment still applies. – Tom Kriek Oct 5 at 9:10
    
@TomKriek What part is not clear? I 've to recover the data as you see in the first paragraph for each ID in an array. After that i've to merge all the data from the different IDs in the way i've written in the second paragraph "n. 3 rows with value 10 and Numbers [273154] [273155] [273159]" – TheMerovingian Oct 5 at 9:44
    
@TomKriek anyway i think that SELECT DISTINCT may do a part of the wotk – TheMerovingian Oct 5 at 9:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.