Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using Max and Sum in the same query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

perceptus
Starting Member

3 Posts

Posted - 10/04/2012 :  23:58:54  Show Profile  Reply with Quote
I have a large amount data on the consumption of beverages and related information.

I would like to query the one table like

Select personname, sum(Calories), max(Calories) from tblbeers

Sum being the maximum amount of calories that the person consumed.
Max being the maximum amount of calories that was consumed of all entries for the person.

Sum and max give me the same information. Is there a work around or am i turning the screw the wrong way.

bandi
Flowing Fount of Yak Knowledge

India
2242 Posts

Posted - 10/05/2012 :  00:40:05  Show Profile  Reply with Quote
Please provide sample data and expected output

--
Chandu
Go to Top of Page

perceptus
Starting Member

3 Posts

Posted - 10/05/2012 :  00:50:12  Show Profile  Reply with Quote
I am unsure about what you are asking. I gave what you asked just not in tabular form. do you want it in tabular form?

I want to return the upper extreme and the mode for the values in calories for all beers consumed by one person.

Edited by - perceptus on 10/05/2012 00:59:06
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 10/06/2012 :  00:26:26  Show Profile  Reply with Quote
quote:
Originally posted by perceptus

I am unsure about what you are asking. I gave what you asked just not in tabular form. do you want it in tabular form?

I want to return the upper extreme and the mode for the values in calories for all beers consumed by one person.


see how to post data for question

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sathiesh2005
Yak Posting Veteran

India
85 Posts

Posted - 10/18/2012 :  07:11:27  Show Profile  Reply with Quote
Select personname, sum(Calories), max(Calories) from tblbeers
Group by personname

@Sathiesh
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000