Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Group By - Help Expand / Collapse
Author
Message
Posted Tuesday, January 22, 2013 3:32 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 10:53 AM
Points: 163, Visits: 612
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
Post #1409896
Posted Tuesday, January 22, 2013 3:52 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, June 13, 2013 7:03 AM
Points: 2,562, Visits: 3,453
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----------
While 1 = 1 (Learning SQL....)
Click to get fast response of your post
Post #1409905
Posted Tuesday, January 22, 2013 3:59 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 10:53 AM
Points: 163, Visits: 612
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
Post #1409908
Posted Tuesday, January 22, 2013 4:41 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 10:53 AM
Points: 163, Visits: 612

Select whitin Select, in order to group by?
Any solution please, thanks

regards
Post #1409937
Posted Tuesday, January 22, 2013 7:50 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 3:12 PM
Points: 8,957, Visits: 8,523
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1410044
Posted Monday, January 28, 2013 8:00 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 3:12 PM
Points: 8,957, Visits: 8,523
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1412447
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse