October 21, 2016 at 8:59 am
hi
i have following query
select id,
name,
value -- its actually total sum for each id
from table A
group by
id,
name
value
here i dont want to use value as it will not get me correct data.how can i avoid it
October 21, 2016 at 9:29 am
coool_sweet (10/21/2016)
hii have following query
select id,
name,
value -- its actually total sum for each id
from table A
group by
id,
name
value
here i dont want to use value as it will not get me correct data.how can i avoid it
If your code is actually does the sum remove value from the group
select id,
name,
sum (value) as idsum
from table A
group by
id,
name
If you just want the sum by ID and not Name then that is a different problem.
October 21, 2016 at 10:36 am
my table already stored value of sum(value) as a value
i just need to take value ,so i cannot do sum(value) in my select statement
October 21, 2016 at 1:15 pm
If value isn't correct and SUM(value) isn't correct, it's not clear what IS correct without sample data and expected results. Please read the first link in my signature to show how to post the data to the forum. You need to make sure that you're posting enough info to demonstrate the problem without overwhelming people. Based on your question, you probably don't need more than 10 rows.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 21, 2016 at 3:36 pm
Who knows, maybe this?
select id, name,
max(value) as value
from table A
group by
id,
name
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply