Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
Group By - Help
Group By - Help
Rate Topic
Display Mode
Topic Options
Author
Message
davdam8
davdam8
Posted Tuesday, January 22, 2013 3:32 AM
SSC-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
Bhuvnesh
Bhuvnesh
Posted Tuesday, January 22, 2013 3:52 AM
SSCrazy
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
davdam8
davdam8
Posted Tuesday, January 22, 2013 3:59 AM
SSC-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
davdam8
davdam8
Posted Tuesday, January 22, 2013 4:41 AM
SSC-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
Sean Lange
Sean Lange
Posted Tuesday, January 22, 2013 7:50 AM
SSCrazy 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
Sean Lange
Sean Lange
Posted Monday, January 28, 2013 8:00 AM
SSCrazy 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 »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.