简体   繁体   English

在SQL中形成Case语句

[英]Forming Case statements in SQL

I need to form a Case statements for the following queries: 我需要为以下查询形成Case语句:

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. T是列名, iwa是表名, art是输入。 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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