Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

need help for sql query Expand / Collapse
Author
Message
Posted Tuesday, August 5, 2014 12:03 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, November 26, 2014 11:36 PM
Points: 21, Visits: 72

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
Post #1599473
Posted Tuesday, August 5, 2014 12:25 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:15 AM
Points: 5,317, Visits: 12,354
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #1599477
Posted Tuesday, August 5, 2014 1:08 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 12:52 PM
Points: 13,636, Visits: 11,509
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 LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1599490
Posted Tuesday, August 5, 2014 1:15 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:15 AM
Points: 5,317, Visits: 12,354
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #1599494
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse