Here is what i am doing:
select case
when SUBSTRING(task_name, 1, 3)= 'PTO'
then Replace(task_name,'PTO','PTO_Holiday')
when SUBSTRING(task_name, 1, 7)= 'Holiday'
then Replace(task_name,'Holiday','PTO_Holiday')
when SUBSTRING(proj_name, 1, 9)= '9900-2831'
then Replace(proj_name,'9900-2831','II Internal')
when SUBSTRING(proj_name, 1, 9)= '9900-2788'
then Replace(proj_name,'9900-2788','II Internal') Line 3 ELSE proj_name,task_name END as Task_Name
FROM dbo._Employee_Time_Detail_Reports INNER JOIN
dbo._vw_Employee ON dbo._Employee_Time_Detail_Reports.res_name = dbo._vw_Employee.Employee
This work fine, however in line THREE i need to show two columns
something like this
ELSE proj_name,task_name END as Task_Name,Project_Name
but this is worng. how can i fix that
3 1257
You need to use two CASE statements like this:
select case
when SUBSTRING(task_name, 1, 3)= 'PTO'
then Replace(task_name,'PTO','PTO_Holiday')
when SUBSTRING(task_name, 1, 7)= 'Holiday'
then Replace(task_name,'Holiday','PTO_Holiday')
ELSE task_name
END as task_name
CASE
when SUBSTRING(proj_name, 1, 9)= '9900-2831'
then Replace(proj_name,'9900-2831','II Internal')
when SUBSTRING(proj_name, 1, 9)= '9900-2788'
then Replace(proj_name,'9900-2788','II Internal')
ELSE proj_name
END as proj_name
FROM ....
Opps, I forgot a comma in between the two case statements.
select case
when SUBSTRING(task_name, 1, 3)= 'PTO'
then Replace(task_name,'PTO','PTO_Holiday')
when SUBSTRING(task_name, 1, 7)= 'Holiday'
then Replace(task_name,'Holiday','PTO_Holiday')
ELSE task_name
END as task_name,
CASE
when SUBSTRING(proj_name, 1, 9)= '9900-2831'
then Replace(proj_name,'9900-2831','II Internal')
when SUBSTRING(proj_name, 1, 9)= '9900-2788'
then Replace(proj_name,'9900-2788','II Internal')
ELSE proj_name
END as proj_name
FROM ....
Thank you SOOO much for your help
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joe Stevenson |
last post by:
Hi all,
I skimmed through the docs for Python, and I did not find anything like
a case or switch statement. I assume there is one and that I just
missed it. Can someone please point me to the...
|
by: ryan.mclean |
last post by:
Hi all, first, let me preface this by saying that I am very new to sql
server, coming from oracle.
Here is my problem: I would like to have a case statement (similar to
decode in oracle) that...
|
by: Chih-Hsu Yen |
last post by:
I encountered a strange problem about switch-case statement.
switch(cmd)
{
case 1: statements; break;
case 2: statements; break;
... ....
case 11: S1;
S2;
S3;
statements;
|
by: mark.irwin |
last post by:
Hello all,
Have an issue where a redirect pushes data to a page with a select case
which then redirects to another page. Problem is the redirect isnt
working in 1 case. Code below:
strURL =...
|
by: |
last post by:
Hello,
This is gonna sound real daft, but how do I test a Select Case statement for
variants of a theme?
Here's a snippet of my code...
Select Case sUsr
Case "Guest", "TsInternetUser",...
|
by: rAinDeEr |
last post by:
Hi,
I have a table with 2 columns
** CREATE TABLE test (emp_num DECIMAL(7) NOT NULL,emp_name CHAR(10) NOT
NULL) and i have inserted a number of records.
** Now, I want to insert a new...
|
by: scole954387 |
last post by:
Hi,
I have a problem. I have written a SQL statement that has a nested
select case statement on the 'where' clause to condition the results.
...
|
by: microsoft.public.dotnet.languages.vb |
last post by:
Hi All,
I wanted to know whether this is possible to use multiple variables to
use in the select case statement such as follows:
select case dWarrExpDateMonth, dRetailDateMonth
case...
|
by: Robbie Hatley |
last post by:
Greetings, group. I just found a weird problem in a program where
a variable declared in a {block} after a "case" keyword was being
treated as having value 0 even though its actual value should...
|
by: beacon |
last post by:
Hello to everybody,
I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know),...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |