【发布时间】:2022-06-27 23:25:20
【问题描述】:
我想要一个查询,它只根据列中的值返回一个输出行。 我需要的是
表 A 有值
A
----|----
1 |
2 |
3 |
required output
A
----
yes
所以我需要一个查询,如果表 a 的列中有 3,那么我需要得到的输出是 yes 或 no。 我的代码:-
WITH
number_tb AS (select * from t1),
out_put as (select case when a = 3 then 'yes' else 'no' end a_case from number_tb)
select * from out_put
output:-
a_case
-----
no
no
yes
我只需要单行输出。如果存在 3,那么是或否,我不需要每一行。 有可能吗?
【问题讨论】:
-
请不要标记垃圾邮件。 PL/SQL 与 Oracle 有关,而 MySQL 和 SQL Server 不是 PostgreSQL。
-
“PostgreSQL 或 SQL”没有意义。 SQL 是一种所有关系型数据库(包括 PostgreSQL)都使用的查询语言
标签: sql postgresql