- 3,715,591 Users
- 2,242,805 Discussions
- 7,845,450 Comments
Forum Stats
Discussions
Categories
- 16 Data
- 362.2K Big Data Appliance
- 7 Data Science
- 1.6K Databases
- 465 General Database Discussions
- 3.7K Java and JavaScript in the Database
- 22 Multilingual Engine
- 487 MySQL Community Space
- 3 NoSQL Database
- 7.6K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 416 SQLcl
- 42 SQL Developer Data Modeler
- 184.8K SQL & PL/SQL
- 21K SQL Developer
- 1.8K Development
- 3 Developer Projects
- 32 Programming Languages
- 135.1K Development Tools
- 8 DevOps
- 3K QA/Testing
- 246 Java
- 5 Java Learning Subscription
- 10 Database Connectivity
- 66 Java Community Process
- 1 Java 25
- 9 Java APIs
- 141.1K Java Development Tools
- 6 Java EE (Java Enterprise Edition)
- 153K Java Essentials
- 135 Java 8 Questions
- 86.2K Java Programming
- 270 Java Lambda MOOC
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 10 Java SE
- 13.8K Java Security
- 3 Java User Groups
- 22 JavaScript - Nashorn
- 18 Programs
- 125 LiveLabs
- 30 Workshops
- 9 Software
- 3 Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 3 Deutsche Oracle Community
- 10 Español
- 1.9K Japanese
- 2 Portuguese
select result without same rows

Hi!
Could you please give me advice, i have some select
select
o.field1,
o.field2,
o.field3,
b.field4,
b.field5
from orders o
inner join bill b
on o.orders_id = b.orders_id
and b.PARAM_ID in ('PARAM1', 'PARAM2', 'PARAM3');
and result set will be something like this, i need to get fields 3-4-5, but field 1-2 will be the same;
field1 field2 field3 (PARAM1)
field1 field2 field4 (PARAM2)
field1 field2 field5 (PARAM3)
...
field1 field2 field3 (PARAM1)
field1 field2 field4 (PARAM2)
field1 field2 field5 (PARAM3)
how i can change it, to get data like this, without repeating field1 field2 and selecting their field 3-4-5 at row :
field1 field2 PARAM1 PARAM2 PARAM3
...
field1 field2 PARAM1 PARAM2 PARAM3
Answers
-
Hi,
Whenever you have a question, please post a little sample data in a usable form (such as CREATE TABLE and INSERT statements), so the people who want to help you car re-create the problem and test their ideas. Also post the exact results you want from the given data, and an explanation (in general terms) of you get those results from that data. Always say which version of Oracle you're using (e.g. 12.2.0.1.0).
See: How to Ask Questions in Developer Community Spaces - oracle-tech
Could you please give me advice, i have some select
select
o.field1,
o.field2,
o.field3,
b.field4,
b.field5
from orders o
inner join bill b
on o.orders_id = b.orders_id
and b.PARAM_ID in ('PARAM1', 'PARAM2', 'PARAM3');
and result set will be something like this, i need to get fields 3-4-5, but field 1-2 will be the same;
field1 field2 field3 (PARAM1)
field1 field2 field4 (PARAM2)
field1 field2 field5 (PARAM3)
...
You must have copied something wrong. The result set of the query you posted will NOT be like the results you posted. The query will produce 5 columns, not 3. (Or is it 4?)
If you don have a query that produces 3 rows, and you change the result set to contain the same values in 3 columns on te same row, that's called Pivoting. Exactly how you do it depends on your data, your requirements and your verfsion.