| | |
CASE function
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 2
Reputation:
Solved Threads: 0
Please, try to help with this. I use case statement but for 2 arguments.
Down here is the idea of what i want to get:
select x case x
when x = 'AB' and y like 'CD%' then x= 'CD'
when x = 'ZZ' and y like 'CC%' then x= 'BA'
when x in ('bbb','sss','ddg') then x= 'BB'
I ll be grateful if anyone would help write right querry.
Thank in advance
Marcel
Down here is the idea of what i want to get:
select x case x
when x = 'AB' and y like 'CD%' then x= 'CD'
when x = 'ZZ' and y like 'CC%' then x= 'BA'
when x in ('bbb','sss','ddg') then x= 'BB'
I ll be grateful if anyone would help write right querry.
Thank in advance
Marcel
•
•
Join Date: Apr 2008
Posts: 296
Reputation:
Solved Threads: 42
hi marcel1,
below select with case clause is standard SQL1999. Maybe it works also on MS SQL Server.
You can also omit the first attribute x from the select, if you don't need original x values.
Like x, y must also be attribute of yourTable.
Maybe this will help you.
krs,
tesu
below select with case clause is standard SQL1999. Maybe it works also on MS SQL Server.
sql Syntax (Toggle Plain Text)
SELECT x, ( CASE WHEN x = 'AB' AND y LIKE 'CD%' THEN 'CD' WHEN 'ZZ' AND y LIKE 'CC%' THEN 'BA' WHEN x IN ('bbb','sss','ddg') THEN 'BB' ELSE 'unknown thing' END ) AS xx FROM yourtable WHERE ... ;
MS SQL Syntax (Toggle Plain Text)
This will produce a list WITH two COLUMNS, FOR example x xx ------------ AB CD sss BB wow unknown thing
Like x, y must also be attribute of yourTable.
Maybe this will help you.
krs,
tesu
![]() |
Similar Threads
- python function call for a noob (Python)
- Computer Won't Function Properly (Troubleshooting Dead Machines)
- Function for assigning variables (Python)
- int function(fstream)//illegal argument (C)
- Anyone here mod their case? (Geeks' Lounge)
- Need help on a program (function bug) (C)
- case and image help please (PHP)
- Function that returns void (C++)
Other Threads in the MS SQL Forum
- Previous Thread: Converting MYSQL statement to MSSQL
- Next Thread: Prevent queries from SQL Injection attack in SQL Server 2005
| Thread Tools | Search this Thread |





