简体   繁体   中英

Forming Case statements in SQL

I need to form a Case statements for the following queries:

select 
Distinct T from iwa b 
where exists (
 select * from iwa where T=320 and art=1234
) 
and exists (
 select * from iwa where T=450 and art=1234 and art=b.art
);

select T from iwa where T=320 where art=1234;

Select T from iwa where T=450 where art=1234;

T is a column name, iwa is a table name and art is an input. I should get an output from all the above queries checked.

I can't understand really what you trying to achieve. Maybe you need something like this?

select T 
from iwa 
where (T=320 and art=1234)
or (T=450 and art=1234)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM