MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 21st, 2004, 12:51 PM
tOeJaM tOeJaM is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: United States
Posts: 46 tOeJaM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 55 sec
Reputation Power: 6
Group by question

salesrep | dollars | months
a1 | $1.00 | 4/1/2004
a1 | $2.00 | 5/2/2004
a1 | $3.00 | 5/3/2004
a1 | $4.00 | 6/4/2004
a1 | $5.00 | 6/5/2004
a1 | $6.00 | 6/6/2004
b1 | $7.00 | 3/7/2004
b1 | $8.00 | 3/8/2004
b1 | $9.00 | 4/9/2004
b1 | $10.00 | 5/10/2004
b1 | $11.00 | 5/11/2004
b1 | $12.00 | 6/12/2004
b1 | $13.00 | 6/13/2004

Given the above data, I need to come up with a report that displays atotal by salesrep by month.

Any help would be greatly appreciated. Getting a total by month is where I'm hung up.
__________________
_________________________
Dual Intel P3 1ghz CPU's
ABIT VP6 dual FC-PGA
720,896mb ECC PC100 RAM
128meg ATI Radeon 9500 Pro
Antec Performance II
White Box Linux r3.0
kernel 2.4.21-9.0.3ELsmp

Reply With Quote
  #2  
Old July 21st, 2004, 09:02 PM
kpinocchio kpinocchio is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 12 kpinocchio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try this:

SELECT salesrep, DATENAME(month, months) As MonthName, SUM(dollars)
FROM tblDeleteMe
GROUP BY salesrep, DATENAME(month, months)
ORDER BY salesrep, DATENAME(month, months)

Don't forget to substitute your table name for my tblDeletMe in the FROM clause.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Group by question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway