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
 please solve the problem

Author  Topic 

ramu143
Yak Posting Veteran

64 Posts

Posted - 2008-09-26 : 01:13:12
select filedate, switchcode, legaport,sum(legatime)/60 as minutes,count(*) as noofcalls,(minutes/noofcalls) as ACD into #mohan from month09..xcda (nolock)
where legaport like 'dac%' and filedate like '2008-09-04' group by filedate, switchcode,legaport order by filedate, switchcode,legaport


i am getting eror like this

Invalid column name 'minutes'
Invalid column name 'noofcalls'


please solve this one give me a responce please

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-26 : 01:17:00
you cant use aliases directly like this.make a derived table and then refer derived columns from it.

select filedate, switchcode, legaport,minutes,noofcalls,(minutes*1.0/noofcalls) as ACD
from
(
select filedate, switchcode, legaport,sum(legatime)*1.0/60 as minutes,count(*) as noofcalls into #mohan from month09..xcda (nolock)
where legaport like 'dac%' and filedate like '2008-09-04' group by filedate, switchcode,legaport order by filedate, switchcode,legaport
)t
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-26 : 01:17:54
and why didnt you refer to solution provided earlier?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=111333
Go to Top of Page

ramu143
Yak Posting Veteran

64 Posts

Posted - 2008-09-26 : 05:34:45
thankive very much vishaka
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-26 : 06:14:16
quote:
Originally posted by ramu143

thankive very much vishaka


you're welcome
Make sure you go through and understand solutions provided here completely and ask if you feel any doubt.
Go to Top of Page
   

- Advertisement -