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
 General SQL Server Forums
 New to SQL Server Programming
 multiply fields

Author  Topic 

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-12 : 02:34:30
Hi. Just a question. Did I use it proper to multiply fields and assign to a variable?

select l.* , e.paytype, e.sectioncode, e.empno,dc.fullname,
earnedDays = lc.earned, availedDays = lc.availed,
earnedHours = (lc.earned * e.hrswork), availedHours = (lc.availed * hrswork),
balHours = (earnedHours - availedHours), balDays = (earnedDays - availedDays)
from hrempleaveledger as l
inner join......
inner join......
.
.
.


I can't surf through the net because i have no permission from the administrator.

Thanks.
-Ron-

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-12 : 02:38:40
Assign it to a variable? Where is variable?

All I can see are some expressions to whom you are giving column names !!

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-12 : 02:41:26
ops im sorry, column name i mean. If i runn my query it has error to all column names i assigned.

thanks.
-Ron-
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-12 : 02:46:00
That is because you are using one computed column to build another one:

select 
l.* , e.paytype, e.sectioncode, e.empno,dc.fullname,
earnedDays = lc.earned,
availedDays = lc.availed,
earnedHours = (lc.earned * e.hrswork),
availedHours = (lc.availed * hrswork),
balHours = (lc.earned * e.hrswork) - (lc.availed * hrswork),
balDays = (lc.earned - lc.availed)

from hrempleaveledger as l
inner join......
inner join......



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-12 : 02:50:32
still not working....

Msg 209, Level 16, State 1, Line 18
Ambiguous column name 'hrswork'.
Msg 209, Level 16, State 1, Line 19
Ambiguous column name 'hrswork'.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-12 : 02:53:28
Can't you take a time to carefully go through what you have written?

select 
l.* , e.paytype, e.sectioncode, e.empno,dc.fullname,
earnedDays = lc.earned,
availedDays = lc.availed,
earnedHours = (lc.earned * e.hrswork),
availedHours = (lc.availed * e.hrswork),
balHours = (lc.earned * e.hrswork) - (lc.availed * e.hrswork),
balDays = (lc.earned - lc.availed)
from hrempleaveledger as l
inner join......
inner join......


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-12 : 02:56:39
thanks harsh. sorry for my stupidity.

yahooo...
-Ron-
Go to Top of Page
   

- Advertisement -