Wednesday, March 28, 2012

Knowing what is grouped?!


Hello!

I have a table "A" like this shown bellow and a problem...

Vr Kon Value ID DZ PRM 22900 -16.00 101 M PRM 22900 16.00 102 P PRM 22900 -728.19 103 M PRM 22900 728.19 104 P


I am doing simle grouping on this table...
Grouping is by Vr,Kon,Dz and Value is summed.

Select is like this
SELECT Vr,Kon,sum(value) from TableA
GROUP BY vr,kon,dz
So, my results look like this:

Vr Kon Value 1 PRM 22900 -744.19 2 PRM 22900 744.19


What I need to know is to somehow link row 1 from my results to IDs 101 and 103 from table and ofcourse row 2 to IDs 102 and 104...
Since english is not my native language i'll try to use colurs in effort to
clarify desired results...

I need to know that row 1 was product of grouping rows with IDs 101 and 103.
So my desired results will look like this...

Vr Kon Value Grouped_IDs 1 PRM 22900 -744.19 101,103 2 PRM 22900 744.19 102,104


or in ideal case same stuff but in relational table... like this:

Result_Row Grouped_ID_From_TableA 1 101 1 103 2 102 2 104

Any thoughts?!

p.s.
I forgot to say that I am working on SQL Server 2000...<marko2511@.discussions..microsoft.com> wrote in message news:167b3c86-3b1e-4611-ab79-4d46cf72284e_WBRev1_@.discussions..microsoft.com...What I need to know is to somehow link row 1 from my results to IDs 1 and 3 from table and ofcourse row 2 to IDs 2 and 4... I'm not sure what "link" means in this context. Can you show the output you're hoping for? -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457--|||I have edited my first post in effort to try clarify things little better...
Please, read again...|||Ah! In that case: http://www.aspfaq.com/show.asp?id=2529 -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <marko2511@.discussions..microsoft.com> wrote in message news:7f30a711-c63a-4a87-b121-bc7ca1388a93@.discussions.microsoft.com...I have edited my first post in effort to try clarify things little better...Please, read again...|||Seams it's should work but it's late at night here so i'll check it in the morning
and get back here with results...
Regards.

No comments:

Post a Comment