Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


need help for sql query


need help for sql query

Author
Message
rajnidas.y
rajnidas.y
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 80
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
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8362 Visits: 19496
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




Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16455 Visits: 13207
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. ;-)



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8362 Visits: 19496
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! :-)


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search