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

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using Max and Sum in the same query

Author  Topic 

perceptus
Starting Member

3 Posts

Posted - 2012-10-04 : 23:58:54
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
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-10-05 : 00:40:05
Please provide sample data and expected output

--
Chandu
Go to Top of Page

perceptus
Starting Member

3 Posts

Posted - 2012-10-05 : 00:50:12
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.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-06 : 00:26:26
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

85 Posts

Posted - 2012-10-18 : 07:11:27
Select personname, sum(Calories), max(Calories) from tblbeers
Group by personname

@Sathiesh
Go to Top of Page
   

- Advertisement -