Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I group a column one or more results in the same column?

User_OMEF8Dec 4 2020

I have a query that returns multiple rows. There is one column that I want to concatenate into the same column. I have a query that can return the result below.

ID | FirstName | LastName | City | State | Phone | SystemDate
1 | John | Doe | ABC | FL | 5555555555 | 2020-12-01
1 | John | Doe | ABC | FL | 8888888888 | 2020-12-01
2 | Jane | Smith | XYZ | CA | 9999999999 | 2020-12-01

What I would like to do is have the output look like this instead.

ID | FirstName | LastName | City | State | Phone | SystemDate
1 | John | Doe | ABC | FL | 5555555555, 8888888888 | 2020-12-01
2 | Jane | Smith | XYZ | CA | 9999999999 | 2020-12-01

Here is my query that can do the first output.
select a.idref, p.firstname, p.lastname, d.city, d.state, m.phone, m.createdate
from master m
join demographics d on m.did = d.id
join commoninfo c on d.eid = c.id
join acounts a on c.aid = a.id
join people p on a.pid = p.id
where m.createdate >= trunc(sysdate + interval '-1' day);

Any tips or hints for this newbie is greatly appreciated. Thanks in advance.

This post has been answered by Solomon Yakobson on Dec 4 2020
Jump to Answer

Comments

Andris Perkons-Oracle

You have to install EPEL (Extra Packages for Enterprise Linux) first.

Use google how to do it or check this blog entry: https://blogs.oracle.com/wim/using-epel-repos-with-oracle-linux. Since you are on OL6, you will have to scroll down to the "Original Content"

Then you should be able to run "yum install python-pip" to install pip.

Andris

Sergio-Oracle

As another option that uses Oracle Linux yum server, see this document about Python for Oracle Linux:

Python for Oracle Linux | Oracle, Software. Hardware. Complete.

If you are OK with using a newer version of Python than the system version: on Oracle Linux 7 you have the option to use newer releases of Python from EPEL (as Andris points out). On OL6 you can use the Software Collection Library. For example:

$ sudo yum -y install yum-utils

$ sudo yum-config-manager --enable ol6_software_collections

$ sudo yum install -y rh-python36 scl-utils

$ # become root

$ sudo su -

# scl enable rh-python36 bash

# python -m pip install Flask

# # first exit out of SCL environment, then out of root

# exit

# exit

$ # should be able to use the flask module now

$ scl enable rh-python36 bash

$ python

Python 3.6.3 (default, Feb 12 2018, 20:00:49)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import flask

>>> quit()

happy10319

Thank you.

But:

[root@rac1 python]# sudo yum -y install yum-utils

Loaded plugins: refresh-packagekit, security, ulninfo

Setting up Install Process

Package yum-utils-1.1.30-40.0.1.el6.noarch already installed and latest version

Nothing to do

[root@rac1 python]# sudo yum-config-manager --enable ol6_software_collections

Loaded plugins: refresh-packagekit

[root@rac1 python]# sudo yum install -y rh-python36 scl-utils

Loaded plugins: refresh-packagekit, security, ulninfo

Setting up Install Process

No package rh-python36 available.

Package scl-utils-20120927-29.el6_9.x86_64 already installed and latest version

Nothing to do

[root@rac1 python]# scl enable rh-python36 bash

Unable to open /etc/scl/prefixes/rh-python36!

[root@rac1 python]#

Thank you.

Sergio-Oracle

Do you have an up to date repo file? See:

http://yum.oracle.com/oracle-linux-python.html#EnablingRepos

happy10319

Thank you.

I do not know. How to verify?

That document does not show how to see that. Does it?

Regards.

Sergio-Oracle
Answer

You can tell by looking in the yum repo file, e.g.

$ grep ol6_software_collection /etc/yum.repos.d/*

[ol6_software_collections]

If you don't see that result, you'll need to obtain a more recent yum repo file as explained here:

Python for Oracle Linux | Oracle, Software. Hardware. Complete.

Marked as Answer by happy10319 · Sep 27 2020
1 - 6

Post Details

Added on Dec 4 2020
2 comments
128 views