Avatar of Tina K
Tina K
Flag for United States of America asked on

Multiple functions in SQL select statement

For some reason, this really has me stumped.  I'm trying to retrieve the max transaction id from the inventory_transaction table, but also need to sum up some costs.  As soon as I start adding any of the costs, no matter how I do it, the max(inventory_trans) fails and I get a record for each different cost.

Example - this works:

this one works
This doesn't:  I get 151 records, rather than the max:

not
Also doesn't work:

also not
Any help appreciated!
Microsoft SQL Server

Avatar of undefined
Last Comment
Tina K

8/22/2022 - Mon
Scott Pletcher

SELECT part_id, MAX(...), SUM(ACT_BURDEN_COST + ...) AS act_cost
FROM ...
WHERE ...
GROUP BY part_id
Tina K

ASKER
Hi Scott -
Gave that a try and get the same result of multiple records:

not-working-III.JPG
ASKER CERTIFIED SOLUTION
Scott Pletcher

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Tina K

ASKER
That did the trick Scott!  Thanks so much!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck