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
 need sql query help

Author  Topic 

rajnidas
Yak Posting Veteran

97 Posts

Posted - 2014-08-04 : 08:52:02

hi all

when i execute the following query i am getting error/
'Unknown column 'Number_of_Leaves' in 'field list''
kindly need help,

(SELECT
CASE
WHEN UPPER(f.newact) = 'N'
THEN c.numberofleavesnew
WHEN UPPER(f.newact) = 'R'
THEN c.numberofleaves
END AS Number_of_Leaves -- ( i want to addition Number_of_Leaves column name and f.STRT_SER)
,(Number_of_Leaves + f.STRT_SER )AS series

FROM finacle_upload_detail AS f INNER JOIN cheque_master AS c ON c.schemecode = f.schcd )


thanks & regards

Rajnidas

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-08-04 : 09:53:55
can you try this
;WITH sums AS
(
SELECT
CASE
WHEN UPPER(f.newact) = 'N'
THEN c.numberofleavesnew
WHEN UPPER(f.newact) = 'R'
THEN c.numberofleaves
END AS Number_of_Leaves ,
f.STRT_SER
--,(Number_of_Leaves + f.STRT_SER )AS series

FROM finacle_upload_detail AS f INNER JOIN cheque_master AS c ON c.schemecode = f.schcd
)
SELECT
Number_of_Leaves + STRT_SER AS series
FROM
sums

Javeed Ahmed
Go to Top of Page
   

- Advertisement -