Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
GROUP BY "Year" using field with full date
Old 11-12-2008, 10:48 AM GROUP BY "Year" using field with full date
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
GROUP BY scenario.

I am trying to figure out how I can group records by year, i.d.,

2007 - 25,000
2008 - 15,000

And the date filed has full date - mm/dd/yyyy

Is there a way to accomplish this?

Thanks for any help

~Chip
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
 
Register now for full access!
Old 11-12-2008, 11:27 AM Re: GROUP BY "Year" using field with full date
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
If you just want to fetch the total, this should do it:
Code:
select count(*)
from table
group by date(date_field)
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 11-12-2008, 11:31 AM Re: GROUP BY "Year" using field with full date
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,516
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Not sure if access supports DATEPART() but try;

GROUP BY DATEPART("yyyy", date_column)
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-12-2008, 11:40 AM Re: GROUP BY "Year" using field with full date
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Thanks for the quick reply Chris. I'll try this. I'll let you know if it works with access.
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 11-12-2008, 11:48 AM Re: GROUP BY "Year" using field with full date
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Hum, my bad... I did not checked for which db.
My solution is only valid for mysql/postgresql.
Sorry.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 11-12-2008, 12:12 PM Re: GROUP BY "Year" using field with full date
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Didn't work with access. It grouped by the full date.

I think I might just add another field that is specifically the Year. Then use this to group by. IN the long run it will probably be quicker..!

Any thoughts?

Thanks,

Chip
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 11-12-2008, 01:37 PM Re: GROUP BY "Year" using field with full date
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Group By Format(dateValue, "yyyy")
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to GROUP BY "Year" using field with full date
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.53938 seconds with 12 queries