SQL Server Forums
Profile | Register | 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
 New Topic  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
2206 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
52317 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  
 New 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.08 seconds. Powered By: Snitz Forums 2000