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.
SELECT DISTINCT
on theIDprestazione
column then do aSELECT DISTINCT
on the value and then list all theNumbers
perValue
– Tom Kriek Oct 5 at 9:02