Avatar of al4629740
al4629740
Flag for United States of America asked on

query syntax - multiply a column by 10 into another column

I need help with query syntax in SQL.  I have the following SQL statement:

select  H.Agency,Count(distinct H.ActivityDate) as [# of days],SUM(Hours) as [Total Hours], ([Total Hours] * 10) as [Check Total], r.LastName,r.FirstName,r.BirthDate " & _
"from tblCYEPHours H inner join tblCYEPRegistrations R on H.Regid = R.RegID Where h.[Hours] > 0 and h.Agency = 'Chicago Area Project' And h.ActivityDate >= '" & DTPicker1 & "' And h.ActivityDate <= '" & DTPicker2 & "' " & _
"group by H.Agency,r.LastName,r.FirstName,r.BirthDate Order by H.Agency,r.LastName,r.FirstName

Open in new window


I have an error with the [Check Total] column calculation.  I am trying to multiply the [Total Hours] by 10 for the [Check Total] column.  What am I doing wrong?
SQL

Avatar of undefined
Last Comment
Darrell Porter

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Darrell Porter

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
al4629740

ASKER
Ok this is what I used:

select  H.Agency,Count(distinct H.ActivityDate) as [# of days],SUM(Hours) as [Total Hours], (((Sum(Hours)) * 10) as [Check Total], r.LastName,r.FirstName,r.BirthDate " & _
"from tblCYEPHours H inner join tblCYEPRegistrations R on H.Regid = R.RegID Where h.[Hours] > 0 and h.Agency = 'Chicago Area Project' And h.ActivityDate >= '" & DTPicker1 & "' And h.ActivityDate <= '" & DTPicker2 & "' " & _
"group by H.Agency,r.LastName,r.FirstName,r.BirthDate Order by H.Agency,r.LastName,r.FirstName

Open in new window


I get incorrect syntax near keyword 'as'
al4629740

ASKER
I made a mistake.  The Hour column is datatype decimal(18, 2) if that makes a difference.
al4629740

ASKER
Found the issue.  I had an extra parenthesis!
Your help has saved me hundreds of hours of internet surfing.
fblack61
Darrell Porter

Glad to be of help.