The display of a single line to multiple columns
Hello Oracle gurus,I am fairly new to the SQL development and hope that someone could help me
I have an ID that repeated several times in 3 different tables based on a condition
For your convenience, you can go
Select a.id,
B.SID,
case when b.state = 1 then 'K' another thing ' n end.
case when c.city = 2 then 'K' another thing ' n end
PRIM one
outer join STATE b left on a.id = b.id
outer join CITY c left on a.id = c.id
Results
ID NAME STATE CITY
1 Peter K N
1 Peter N K
Stewie 2 K N
2 Stewie N K
An additional line is coming because of Peter, his State Y and Y for the city.
Expected results
ID NAME STATE CITY
1 Peter K K
Stewie 2 N N
How can I achieve this? I think I can do a union. but my actual query made 140 columns. so, I'm curious to know if there is another way to address the issue?
Is it possible to use separate?
Thanks in advance.
What about
select
a.elig_id,
max(case when b.part_supp_id= 2 then 'Y' else 'N' end) as A,
max(case when b.part_supp_id=21 then 'Y' else 'N' end) as B
from
Elig_Test a
,Elig_Suppr b
where
a.elig_id=b.object_id
group by
a.elig_id
Tags: Database
Similar Questions
-
How to get the result of a single line in several columns
I have a scenario where I asked five different columns in a table and it would still look back one line.
So, for example: the query would be
So, this would mean 1 row with the value of their respective areas.Select user1, user2, user3, user4 from table1 where tblkey= 2
In my code, I have a common function I can call to send an email to the list of people (User1, User2, user3, user4).
So rather than call this function each time for each user, is there a way I can display the output to 4 different rows and use the loop For to call this function only once.
In this way, the loop For running 4 times (if not nulls for all users) and call this function of e-mail.
Really, I'd appreciate if someone could give me an idea of this scenario.
Thank you
ARIf the number of columns is fixed you may be able to use this:
SELECT DECODE ( RN , 1,USER1 , 2,USER2 , 3,USER3 , 4,USER4 ) AS USERS FROM TABLE1 CROSS JOIN (SELECT ROWNUM RN FROM DUAL CONNECT BY ROWNUM <= 4) WHERE TBLKEY = 2
This UN-pivot results.
Here's an example of it in action:
SQL> CREATE TABLE TABLE1 2 ( 3 TBLKEY NUMBER 4 , USER1 VARCHAR2(1) 5 , USER2 VARCHAR2(1) 6 , USER3 VARCHAR2(1) 7 , USER4 VARCHAR2(1) 8 ); Table created. SQL> INSERT INTO TABLE1 2 SELECT ROWNUM 3 , SUBSTR(OBJECT_NAME,1,1) 4 , SUBSTR(OBJECT_NAME,2,1) 5 , SUBSTR(OBJECT_NAME,3,1) 6 , SUBSTR(OBJECT_NAME,4,1) 7 FROM ALL_OBJECTS 8 WHERE ROWNUM <= 10; 10 rows created. SQL> SELECT * FROM TABLE1 WHERE TBLKEY = 2; TBLKEY USER1 USER2 USER3 USER4 -------------------- ---------- ---------- ---------- ---------- 2 I _ U S SQL> SELECT DECODE 2 ( 3 RN 4 , 1,USER1 5 , 2,USER2 6 , 3,USER3 7 , 4,USER4 8 ) AS USERS 9 FROM TABLE1 10 CROSS JOIN (SELECT ROWNUM RN FROM DUAL CONNECT BY ROWNUM <= 4) 11 WHERE TBLKEY = 2 12 / USERS ------------------------- I _ U S
HTH!
Published by: Centinul on February 24, 2010 11:21
-
How to merge data from the table with a single line
Hello
I have three tables subscription_type, the address and the person. Here are the details of the table
Person Subscription_type Address
Person_Id AdressType_id Address_id
Person_name Description Address_type_id
Person_id
Address details
There are three types of different address - home, postal and previous.
Each person can have these three different addresses.
I want to create a view that displays all addresses of three of each person in the table of the person in a single line.
Any help please
In your example, there are 2 rows of columns street1, TOWN, SUBURB etc for a single person. To convert this into a single line, with the new columns we could simply use CASES or DECODE in the select as the SQL below. To understand why consolidation function THAT MAX is used - remove the MAX and GROUP BY in SQL keyword and try.
Select full_name
, max (case when description = "Home" then end street1) Home_Street
, max (case when description = "Home" then end suburb) home_suburb
, max (case when description = end of the "Home" then City) home_city
, max (case when description = "Home" then postal code end) home_postcode
, max (case when description = "Home" then end state_name) home_state
, max (case when description = 'Postal' then end street1) Postal_Street
, max (case when description = 'Postal' and then end of suburb) Postal_suburb
, max (case when description = 'Postal' then the city) Postal_city
, max (case when description = 'Postal' and then end of CP) Postal_postcode
, max (case when description = 'Postal' then state_name end) Postal_state
, max (case when description = "Back" then end street1) Prev_Street
, max (case when description = "Back" then end suburb) Prev_suburb
, max (case when description = "Back" then city end) Prev_city
, max (case when description = "Back" then postal code end) Prev_postcode
address a
S State
No p
Subscription_type att
where a.person_id = p.person_id
and a.state_id = s.state_id
and a.address_type_id = att.address_type_id
Full_name group
-
selection menu/popup/back of the box to a single line
I am trying to program a control that allows the user to choose among 7 different options. The options are each other and collectively exhaustible (in other words, one must be selected at all times). I tried a menu box that begins with a single visible line (the line that contains the currently selected choice). Is that I wish it works: - when the user clicks on the box, all of the 7 choices appear - the movements of the user the cursor on the desired selection and releases (or clicks; I don't like) - the new selection 'takes' - the box comes back to the display of line one, I have the first part of work, but I can't find the right event (s) to do the rest. I'm on the right track? Suggestions to make this work? Thank you.
I agree that any type of control of the ring is a good choice, an appropriate event is EVENT_VAL_CHANGED.
But I also remind you that the CVI comes with a large collection of examples of programs, some of them also include controls of the ring. Analyze these samples can also familiarize themselves with CVI.
-
I want to be able to set the spell checker to occur automatically, even for single-line text boxes.
You can set the pref layout.spellcheckDefault to 2 on the topic: config page to perform spell checking on line and unique multi line text fields.
To open the topic: config page, type Subject: config in the address bar (address) and press the 'Enter' key, as you type the url of a Web site to open a Web site.
If you see a warning then you can confirm that you want to access this page.- Use the filter at the top bar of the on: page config to more easily spot a preference.
- Preferences that have changed see the bold (user set).
- Preferences you can restore the default value or change via the context menu.
-
Add the elements of a single line/column of a matrix
Hi all
What is the best way to add all the elements of a single row or column of a given matrix the matrix and the number of this line/column on LabVIEW? The output should be a number for each row or column.
ARIJ,
You always said not if you use a table or a matrix.
The transposition has to be out of the loop.
This will give you the sum of all rows and all columns.
These are functions and LabVIEW base constructions. If you do not understand the concepts, please visit the online tutorials.
Lynn
-
join in the query with the result of a single line
Hi all
I have two tables
I insert the following recordscreate table item(item_id number primary key, item_desc varchar2(200)); create table item_properties(item_id number references item(item_id), property_name varchar2(20), property_value varchar2(100));
now I want a query that produces the following resultsinsert into items values(1,'CPU'); insert into item_properties values(1,'RAM','2gb'); insert into item_properties values(1,'PROCESSOR','2ghz'); insert into item_properties values(1,'HARDDISK','2ghz'); commit;
How to generate this result?item_id RAM PROCESSOR HARDDISK 1 2gb 2ghz 2TB
I create a query, but it generates several lines, instead I need a single line like above.
Kind thanks.select i.item_id,p.property_value from items i , item_properties p where i.item_id=p.item_id and i.item_id=1;
Published by: Maahjoor on May 7, 2013 12:22 AMselect i.item_id, max(decode(p.property_name,'RAM',p.property_value)) ram, max(decode(p.property_name,'PROCESSOR',p.property_value)) processor, max(decode(p.property_name,'HARDDISK',p.property_value)) hd from items i , item_properties p where i.item_id=p.item_id and i.item_id=1 group by i.item_id;
Or pivot to 11g
with details as ( select i.item_id,p.property_name,p.property_value from item i , item_properties p where i.item_id=p.item_id and i.item_id=1 ) select * from details pivot ( max(property_value) for property_name in ('RAM','PROCESSOR','HARDISK') );
Published by: JAC on May 7, 2013 13:04
-
How to display the results of a MySql query in multiple columns?
Hi, I know how to display PHP/MySq
l of the results in a single column, but I'm really stuck to show
Ying the results of several columns in DW CS4.
Can someone help me with a code example? I'm new to php/mysql. Thank you
Are you asking how to rotate the query results? Do a search for a horizontal loop. If this isn't what you're asking, please provide more details.
-
Hide all instances of the subform with a single line of javascript
Is it possible to hide all instances of a subform with a single line of javascript? I'm looking for something like this:
repeatingSubform [*] .its presence = "hidden";
but which caused the designer...
Or do I have to loop through all instances of the subform and disable individually each of them?
Thank you
Elaine
You must disable them individually
Paul
-
can I customize the display of a single Web site, instead of solving for all?
I have two very similar intranet applications, one part of the production, other development. I don't have any options with the creation or maintenance of these sites, but they appear exactly the same when I work in test 1, in the other. I would like to change the display fonts or colors, or something to help me to make the distinction between the two applications. Can you offer any suggestions?
Thank you- Install Stylish and restart Firefox when prompted.
- Click on the stylish icon on the navigation toolbar and select Write New Style and then blank style.
- Paste the following text in the text box. Change the style according to your needs: in particular, to change the URL at the top.
- Type a name for the style, and then click the "Save" button.
@-moz-document url-prefix("https://support.mozilla.org/en-US/questions/") { body::before { content: "DEVELOPMENT SITE" !important; display: block !important; font: bold 14pt "Segoe UI" !important; background: maroon !important; color: mintcream !important; } }
If you do not want to install an add-on, you can use the file userContent.css instead, but I do not recommend.
- Install Stylish and restart Firefox when prompted.
-
replace the carriage return, displaying the output on a single line
[oracle@ccoshs02xvdbs01 ~] $ sqlplus deploy_ctl/deploy_ctl
SQL * more: Production version 11.2.0.1.0 on Mon Mar 28 10:21:05 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing options
Modified session.
10:21:05 SQL > insert into test (b) values ("this is stop
10:21:38 2 space are now ');
1 line of creation.
10:21:47 SQL > commit;
Validation complete.
10:21:49 SQL > select test b where b as "this % ';
B
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It is stop
space wear now
10:22:07 SQL > select replace (b, chr (13)) of the test where b as "this % ';
REPLACE (B, CHR (13))
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It is stop
space wear now
10:22:56 SQL > select replace (b, chr (13), chr (32)) test fix where b as "this % ';
DIFFICULTY
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It is stop
space wear now
10:24:19 SQL >
I would lilke to display on the same line.
Thank you.Hello
SQL> select translate(b,chr(13)||chr(10),chr(32)) fix from test where b like 'this%'; FIX ---------------------------------------------------------------------------------------------------- this is stopspace now carry on SQL> select translate(b,chr(13)||chr(10),' ') fix from test where b like 'this%'; FIX ---------------------------------------------------------------------------------------------------- this is stopspace now carry on
-Pavan Kumar N
-
Hello
My java code does not build in jdev if I leave this line in java tissue BPEL code
Criteria of SearchCriteria = new SearchCriteria (AttributeName.USER_LOGIN.getId (), une_chaine, SearchCriteria.Operator.EQUAL);
With the help of Jdev 11.1.1.7.0
oimclient is inside of the SCA-INF/lib, manifest says it is version 11.1.2.2.0
Error message does not say much
at com.collaxa.cube.lang.compiler.template.CubeProcessGenerator.compile(CubeProcessGenerator.java:313) at com.collaxa.cube.lang.compiler.template.CubeProcessGenerator.generate(CubeProcessGenerator.java:169)
at com.collaxa.cube.lang.compiler.BPEL1Processor.transform(BPEL1Processor.java:257)
at com.collaxa.cube.lang.compiler.BPEL1Processor.process(BPEL1Processor.java:161)
at com.collaxa.cube.lang.compiler.CubeParserHelper.compile(CubeParserHelper.java:47)
at oracle.fabric.bpel.bpelc.BPELComponentValidator.validate(BPELComponentValidator.java:40)
at oracle.soa.scac.ValidateComposite.validateComponentTypeServicesReferences(ValidateComposite.java:1066)
at oracle.soa.scac.ValidateComposite.doValidation0(ValidateComposite.java:514)
at oracle.soa.scac.ValidateComposite.doValidation(ValidateComposite.java:493)
at oracle.soa.scac.ValidateComposite.run0(ValidateComposite.java:214)
at oracle.soa.scac.ValidateComposite.run(ValidateComposite.java:195)
at oracle.soa.scac.ValidateComposite.main(ValidateComposite.java:187)
Do I need exactly the same version of jdev to oimclient?
TIA
Leo
Well it seems to work when I remove all imports, even classes in java.util. as map, list, etc.
-
How to display the "display values" in single PLAY mode for a SHUTTLE service
Hello
I have a form of type element * 'Shuttle' * and using the following LOV.
In normal mode, it displays the name of the service and retain in-house the Deptno...select DEPTNAME d, DEPTNO r from DEPT
Now, I converted this point in read-only mode using read only Type of Condition
the problem is as soon as it becomes read-only... it displays the deptno... not the name of the service
How can I view the "show values" that is to say the name of the actual service in read-only mode...Department- 10:20:30
Thank youDepartment- Department1:Department2:Department3
DeepakHello
It seems characteristic. Shuttle is the span tag when it is read-only.
Work around could be the one
you calculate display as text with LOV element display value according to shuttle session state and show the shuttle and this conditionally dependent element of the caseBR, JAri
-
the display vertical and horizontal lines
Help, I went simply to connect and it's my screen. You want to know if it is a known problem and if they should solve this problem, I bought it in January 2013. How is that going to cost I only had a one year apple care. What is the problem with that?
same problem as mine, I think that his problem with caused by a discreet graphics card overheating
What model your MBP is? MBP repair extension for 2011 model is now underway, which ends February 2016
Apple will replace your free logicboard if your model is matches the list of the products concerned.
If this is not... just prepared about $200 for reballing the chipset vga (price in my country) or more for replacing logicboard.
-
Why my ListView items cannot display on a single line?
ListView { preferredHeight: ui.du(20) id: keyItemList dataModel: _nao.keyItemList leftPadding: 20 rightPadding: 20 // layout: StackListLayout { orientation: LayoutOrientation.LeftToRight headerMode: ListHeaderMode.None } listItemComponents: [ ListItemComponent { type: 'item' Container { preferredHeight: ui.du(20) preferredWidth: ui.du(20) KeyItem { name: ListItemData.name nowPic: ListItemData.nowPic dot: ListItemData.dot rate: ListItemData.rate } topMargin: ui.du(1.0) leftMargin: ui.du(1.0) rightMargin: ui.du(1.0) bottomMargin: ui.du(1.0) } } ] verticalAlignment: VerticalAlignment.Center horizontalAlignment: HorizontalAlignment.Center }
If I put prop of listview layout. Items being passed.
If I didn't put any accessories page layout, the elements present, but vertically.
It can be a little difficult to get the horizontal listviews to behave, dimensions should be set correctly if I remember correctly.
See https://github.com/oniongarlic/bb10-hlv-example/blob/master/assets/main.qml for an example code.
Maybe you are looking for
-
Something hinky (and no, it is not a virus). Following an 'Upgrade' of v40, I started to experience problems. When I open Thunderbird, it shows my home, not my Inbox tab. If I select my Inbox, the window does not change. By clicking on the "Read Mess
-
Satellite S50D - A - 10 L - Low FPS while playing CS GO
Hi all The other day (Toshiba Satellite S50D - A - 10 L), I bought a Toshiba laptop and my fps where the game is not very high. I looked online to see what the problem might be and discovered that laptops use sometimes the graphics card shipped inste
-
Impossible to read some data on my Satellite A100-413 CD
Hello I bought a Satellite has 100-413 the year last in Luxembourg.I then moved to the Canada (where I put my DVD Zone 1) and reading and burning CDs and DVDs in both countries without any problems so far. I came to Luxembourg for Christmas about a m
-
using the color laserjet 3600n - I want to print in black and white, but it prints black and white negative. * beep *.
-
Mac: Officejet 6500 e710n wireless connectivity problems
Printer: HP Officejet 6500 e710n-z Mac OS x Lion 10.7.5 I have successfully been printing wirlessly with my Offiject 6500 e710n for over a year. Connectivity comes and goes but I was always able to reconnect them by restarting the printer or reconnec