对不起,标题不清楚
我有一个脚本(使用Pl/Sql Oracle),我已经创建了一个报告,将选择退出由用户选择的城市列表。我有一个列将列出该城市,但我想包括一个额外的列,列出与用户相关联的其他城市(城市列表不应包括他/她在该列上的选择)。
我不确定该由谁来执行此操作,因此附加的列将不会列出所选的一个或多个城市。有没有可以使用的函数?
我也在Crystal reporting 10上这样做(如果可能的话)
Iex:这只是我想要做的一个想法。
##Table Name: Giving Cities##
##Andrew - Peru##
##Andrew - Venezuela##
##Andrew - France##
##Paul - USA##
Pick cities where user = Andrew and City = Peru输出
User, City, Other Given Cities发布于 2017-01-31 08:45:49
在SQL中添加额外的列:
select user,cities,'' as additional_columns from yourtable发布于 2017-01-31 09:08:20
我想这就是你要找的:SQL Query to concatenate column values from multiple rows in Oracle
它看起来与您尝试将多个行的结果连接在一起所做的事情完全一样。
至于不为附加列选择“选定的”城市,您可能希望使用子选择。subselect允许您将不同的where子句应用于其他列。
select t.user, t.city, t2.concatenated_cities
from table t
inner join
(
select distinct <see above link for how to concatenate rows here> as concatenated_cities
from table sub_t
where sub_t.city <> 'CITY'
) t2
on t.user = t2.user
where t.city = 'CITY'https://stackoverflow.com/questions/41946465
复制相似问题