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 ««12

Urgent Query help needed- calculate one field based on other field in SELECT statment Expand / Collapse
Author
Message
Posted Tuesday, April 16, 2013 4:40 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, April 24, 2013 7:40 AM
Points: 400, Visits: 38

Is type casting required?. I think it is not required. Even though it is a varchar type, SQL Engine will convert it internally in this scenario. Please correct me, if I wrong.

The below code will work:

CASE
WHEN [Age (Working Days)] < 30
THEN '1 - 29'
WHEN [Age (Working Days)] < 60
THEN '30 - 59'
WHEN [Age (Working Days)] < 90
THEN '60 - 89'
WHEN [Age (Working Days)] < 120
THEN '90 - 119'
ELSE'120 +'

Post #1442676
Posted Tuesday, April 16, 2013 4:54 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, October 27, 2014 6:52 AM
Points: 90, Visits: 182
The code is working good for me :)

thanks
Dhananjay
Post #1442682
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse