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

hi marcel1,
below select with case clause is standard SQL1999. Maybe it works also on MS SQL Server.

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 ... ;
This will produce a list with two columns, for example
x         xx
------------
AB       CD
sss       BB
wow     unknown thing

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

That works just fine.
Thanks
Marcel

I want to thank tesu as well. This helped me out a lot!
Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.