August 5, 2014 at 12:03 am
hi all ,
i need to addition to column which i given below.
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
FROM finacle_upload_detail AS f INNER JOIN cheque_master AS c ON c.schemecode = f.schcd.
getting result.
----------------------
numberofleaves STRT_SER
50 12300
25 45200
30 14522
i need to addition this two column kindly need help
Thanks\
Rajnidas
August 5, 2014 at 12:25 am
Unless your database is case-sensitive, you don't need the UPPERs.
Also you should always qualify your tables with their schema.
So I've rewritten your query a little to account for the above.
with Sub1
as (
select Number_of_Leaves = (
case
when f.newact = 'N'
then c.numberofleavesnew
when f.newact = 'R'
then c.numberofleaves
end
)
,f.STRT_SER
from dbo.finacle_upload_detail f
join dbo.cheque_master c on c.schemecode = f.schcd
)
select s.Number_of_Leaves
,s.Strt_Ser
,Tot = s.Number_of_Leaves + s.Strt_Ser
from Sub1 s
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
August 5, 2014 at 1:08 am
Phil Parkin (8/5/2014)
Unless your database is case-sensitive, you don't need the UPPERs.Also you should always qualify your tables with their schema.
And you should finish your statements with the semicolon operator. 😉
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
August 5, 2014 at 1:15 am
Koen Verbeeck (8/5/2014)
Phil Parkin (8/5/2014)
Unless your database is case-sensitive, you don't need the UPPERs.Also you should always qualify your tables with their schema.
And you should finish your statements with the semicolon operator. 😉
Hah, yes! 🙂
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply