0

Sorry the title isn't clear

I have a script (using Pl/Sql Oracle), i have created a report that will optout a list of cities chosen by a user. I have a column that will list that city but i wanted to include an additional column that list other cities associated with the user (the cities list should not include his/her pick on that column).

I am not exactly sure who to do that so that the additional column will not list the picked city or cities. Is there a function i can use?

I am also doing it on Crystal reporting 10 (if it possible there)

Iex: This is just an idea of what i am trying to do.

##Table Name: Giving Cities##
##Andrew - Peru##
##Andrew - Venezuela##
##Andrew - France##
##​Paul - USA##

Pick cities where user = Andrew and  City = Peru

Output

User, City, Other Given Cities
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
user3139937
  • 111
  • 1
  • 10

2 Answers2

0

In SQL adding extra additional columns:

select user,cities,'' as additional_columns from yourtable
Vijunav Vastivch
  • 4,153
  • 1
  • 16
  • 30
0

I think this is what you are looking for: SQL Query to concatenate column values from multiple rows in Oracle

It looks like exactly what you are trying to do with concatenating the results of multiple rows together.

As for not selecting the "selected" city for the additional column, you would want to use a subselect. A subselect allows you to apply a different where clause to the additional column.

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'
Community
  • 1
  • 1
jaynik
  • 68
  • 6