0

您好,首先我是一个 SQL 新手,需要一点帮助。我找不到和我一模一样的问题。

(select count(*)  from table  where Column_x like '%text1%')
(select count(*)  from table  where Column_x like '%text2%')
(select count(*)  from table  where Column_x like '%text3%')

所以我希望搜索返回

case 1  | Case 2  | Case 3
xtimes   ytimes     ztimes

任何帮助都会很棒,要么只显示查询结果,要么创建一个临时表。

干杯,

我找到的解决方案如下

Select * from(
(select count(*)  as col1 from table  where Column_x like '%text1%')col1,
(select count(*)  as col2 from table  where Column_x like '%text2%')col2,
(select count(*)  as col3 from table  where Column_x like '%text3%')col3

)

4

1 回答 1

0
select * from (
        (select count(*)  from table  where Column_x like '%text1%') as xtimes,
        (select count(*)  from table  where Column_x like '%text2%') as ytimes,
        (select count(*)  from table  where Column_x like '%text3%') as ztimes
        );
于 2013-09-11T23:13:50.837 回答