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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 function on multiple values??

Author  Topic 

krish001
Yak Posting Veteran

61 Posts

Posted - 2009-10-27 : 13:49:52

I have written a function which returns CNT values but my cnt is returning only one value when there are multiple values

how can i solve this??

mfemenel
Professor Frink

1421 Posts

Posted - 2009-10-27 : 13:54:03
you'd have to output your results to a table variable instead of using a scalar function.

Mike
"oh, that monkey is going to pay"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-27 : 13:55:42
quote:
Originally posted by krish001


I have written a function which returns CNT values but my cnt is returning only one value when there are multiple values

how can i solve this??


you need to post your function for us to see if its table valued or scalar. in any case, what you be having is table valued function
Go to Top of Page

krish001
Yak Posting Veteran

61 Posts

Posted - 2009-10-27 : 15:50:35
quote:
Originally posted by visakh16

quote:
Originally posted by krish001


I have written a function which returns CNT values but my cnt is returning only one value when there are multiple values

how can i solve this??


you need to post your function for us to see if its table valued or scalar. in any case, what you be having is table valued function



create function name
declare @cnt int
select @Cnt=isnull(max(Datediff(day,TaskStartDate,TaskFinishDate)),0)
from (select ProjectUID,TaskName,Min(TaskStartDate) as TaskStartDate
from Msp_EpmTask_UserView
where TaskName = 'Audit Field Work'
group by ProjectUID, TaskName) afw
inner join
(select ProjectUID, TaskName,TaskFinishDate from Msp_EpmTask_UserView
where TaskName = 'Final Report Circulation date')frc
on afw.ProjectUID = frc.ProjectUID where afw.Projectuid in
(select projectuid from msp_epmProject_Userview
Where ProjectStartDate >= '01-01-2009' and ProjectFinishDate <='12-12-2009' and BU='wbpo' and [Audit Type]='fa'
and [Status of Audit]='Completed'
GROUP BY BU,[Audit Type],projectuid) group by afw.TaskStartDate,frc.TaskFinishDate,afw.ProjectUID
order by TaskStartDate
Go to Top of Page
   

- Advertisement -