有没有办法做这样的事情(来自嵌套子查询的条件选择):
SELECT
Id,
Name WHERE Name LIKE '%Peter%' AS Peters,
Name WHERE Name LIKE '%Mike%' AS Mikes
FROM
(SELECT Id, Name FROM Customer) myset
答案 0 :(得分:0)
怎么样:
SELECT
Id,
case when Name LIKE '%Peter%' then Name else null end AS Peters,
case when Name LIKE '%Mike%' then Name else null end AS Mikes
FROM
(SELECT Id, Name FROM Customer) myset
此外,您可以直接使用该表。
答案 1 :(得分:0)
select Id, Peters, Mikes
from(
select
case when Name like '%Peter%' then Name end as Peters,
case when Name like '%Mike%' then Name end as Mikes
from Customer)t