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.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
How to use count with Max...
Old 09-18-2008, 12:50 AM How to use count with Max...
Novice Talker

Posts: 10
Name: Sudha
Trades: 0
got a problem here....
i have a existing query which looks like this

SELECT Format(Max(dm_activity.time_from),"yyyy") AS MaxStartYear, dm_activity.Well_id
FROM dm_activity
GROUP BY dm_activity.Well_id

and produces results like this

MaxStartYear Well_id
20085d4X3MVSmm2007 9F0RH26EGK2006BalVGNtKDm2008 dHNS4jPZc42008 lyhdXS4LeF2008NWUF8Rd8sK2007 or5NEAiVj22007uZKMibsDnS

this is good. but now i want to develop this query to get the count of the years. for example i want to get 2008 has 4 counts.....2007 has3 counts...and the table should look like this

2006 12007320084

could someone help me to develop this query to get this result? thanks heaps.,...
kandy1984 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-18-2008, 04:57 PM Re: How to use count with Max...
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Try adding Count(*) as a column in your select list? I'm not sure exactly what you're asking, so I don't know if that will satisfy your requirement.

You could alternatively get the year either by querying the base table directly, the results of your query, etc, then go back to the base table with a Select Count(*) Where query.
__________________

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
 
Old 09-19-2008, 06:03 AM Re: How to use count with Max...
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
This isnt tested but might help you make a start

Code:
SELECT DISTINCT dm2.Year, (SELECT COUNT(*) FROM dm_activity dm1 WHERE dm1.Year=dm2.year) As [Count] FROM dm_activity dm2
Stoot.
stoot98 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to use count with Max...
 

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 1.12584 seconds with 12 queries