January 22, 2013 at 3:32 am
Hi geniuses, I need some help with a query I need for a report, here's what my table contain:
Project | ReceiverGroup | PayingGroup | Value(€)
P1 | A | A | 1
P2 | A | B | 3
P3 | A | C | 2
P4 | A | D | 1
P1 | B | A | 3
P2 | B | B | 2
P3 | B | C | 1
P4 | B | D | 2
I need a query to retreive something like:
----------------------------------------------------------
| €ValuesReceived | €ValuesPayed
----------------------------------------------------------
A | 7 | 4
----------------------------------------------------------
P1 | 1 | 4
P2 | 3 | 0
P3 | 2 | 0
P4 | 1 | 0
----------------------------------------------------------
B | 8 | 5
----------------------------------------------------------
P1 | 3 | 0
P2 | 2 | 5
P3 | 1 | 0
P4 | 2 | 0
----------------------------------------------------------
C | -- | 3
----------------------------------------------------------
D | -- | 3
----------------------------------------------------------
Thanks for your help guys!
Best regards
January 22, 2013 at 3:52 am
PLease post table definition along with sampled data and also the expected output. people here steal time from their busy scehdule sometimes they dont have enough time to frame everything and give the solution.
See the link in my signature
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
January 22, 2013 at 3:59 am
SQL Newbie here!
Sorry, don't have any data on the table yet, this is a projection of what it will contain.
I apreciate all the help I can get for this query.
thanks
regards
January 22, 2013 at 4:41 am
Select whitin Select, in order to group by?
Any solution please, thanks
regards
January 22, 2013 at 7:50 am
davdam8 (1/22/2013)
SQL Newbie here!Sorry, don't have any data on the table yet, this is a projection of what it will contain.
I apreciate all the help I can get for this query.
thanks
regards
The point here is that you didn't provide enough information for others to help. If you can post ddl (create table scripts), sample data (insert statements) and desired output based on your sample data we can help. As previously mentioned please the best practices article. You can find it at the first link in my signature.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
January 28, 2013 at 8:00 am
Do you still need help with this or did you figure it out?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply