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
Tags: Database
Similar Questions
-
How to export data from the table with the colouring of cells according to value.
Hi all
I use jdeveloper 11.1.1.6
I want to export data from the table with a lot of formatting. as for color cells based on value and so much. How to do this?
You can find us apache POI-http://poi.apache.org/
See this http://www.techartifact.com/blogs/2013/08/generate-excel-file-in-oracle-adf-using-apache-poi.html
-
How publish data from the table with some data loss all post in the forum
I wonder how people are displayed the data in the table or the result of a query with losing them its format from Sqlplus display when they post in the forums of Oracle. I searched on the basis of knowledge of DB but I see no article about it. can you please help me or direct me to this link, I tried different options using code and other tags but nothing has worked, thank you for your help. Thank you.
Edited by: Ariean October 3, 2011 12:34You can click on the link to the FAQ at the top right: http://wikis.sun.com/display/Forums/Forums+FAQ.
-
How to send data from the Page with a form to fill out?
How can I automatically include the page title or any text in my Web page when my client click on the Submit button in a form to fill out?
This may seem obvious, but if you want to receive data from a form, and then place it in the form. A hidden form field with the title page and the text of your Web page will send these data on the form submission.
best,
Shocker
-
pl/sql block, reading the reading of data from the table to a single point in time
I'm trying to figure out if several cursors in a PL/SQL block are executed inside a single Point in time, and so don't see no updates of paintings by other processes or procedures running at the same time.
The reason why I ask is I have a block of code as an initial extraction of data, with some Sanity Check before the code runs. However, if another procedure might modify the data between the two, then the mental health check is not valid. So I am essentially trying to know if there is consistency read in a PL/SQL, preventing updates to other processes to be seen.
Anyone who has an idea?
BR,
ChambazGoogle SET Transaction.
or
Follow this link
http://download-West.Oracle.com/docs/CD/B12037_01/server.101/b10759/statements_10005.htm
Kind regards
Prazy -
How to save data from the COM port to file?
Hi all
can someone tell me please how to save data from the COM port on file? I transfer 1 byte of serial port... attached is the image of the vi... very basic.
I would like to save the data in a table... I mean, 1 data--> data--> data tab 2 tab 3rd--> tab
and so on... can anyone help?
-
How to insert data into the table by using the expression builder in the assign activity
How to insert data into the table by using the expression builder in affect business in BPEl, I use SOA Suite 11.1.1.5
Can someone help me pleaseHello
I don't think that oraext:query-database() can insert data into the table.
What are your needs?
Can not you plan to use the DB adapter with the insert operation?Kind regards
Neeraj Sehgal -
data from 3 tables with later dates
Hello
Need help with the PL/SQL code, I need to write a code that will get the data from 3 tables with the most recent date.
For an individual ACT_CODE the output of the SQL query should display the data including the last dates back to 3 tables, if there is no
Date of the table, it should show the remaining data (think that the left join will do here)
Names of tables:
Institution_UPDT aiu
AC ASQ_CONTACT
GR_AUTHORIZE gr
All 3 tables have ACT_Code in common
Column names
INSTITUTION_UPDT IAU - IAU. ACT_CODE, AIU.project_id as proj, IAU. UPDT_TYPE_ID, IAU. User_id, IAU. UPDT_DATE
ASQ_CONTACT ac - ac. ACT_CODE as contact_code, ac.project_id, ac.first_name, ac.middle_initial, ac.last_
Name, AC.title, AC. Status, AC.status_date
GR_AUTHORIZE gr - GR ACT_CODE as grad_code, gr.name, gr.title AS grad_title, gr.submit_date
Are the names of the columns date
AC.status_date,
IAU. UPDT_DATE and
Gr.submit_date
Thanks to you all
appreciate your help
JeshHi, Ngoumba,
If a given ACT_Code couldn't miss from any of the tables, then you will use better full outer joins, not a join left outer.
Perhaps it would be more effective to make a UNION of the three tables, then rotate the results in three datecolumns.
You can use the GROUP BY aggregation to get the last date for each ACT_Code in each table.
If you need other columns in the row which is the last date, you can use the ROW_NUMBER analytic function, like this:SELECT ACT_Code , updt_date , ROW_NUMBER () OVER ( PARTITION BY ACT_Code ORDER BY updt_date DESC ) AS r_num FROM institution_updt
The lines with r_num = 1 are the most recent
This is a technique of ot the UNION-PIVOT example:
WITH union_data AS ( SELECT ACT_Code , MAX (updt_date) AS last_date , 1 AS table_id FROM institution_updt GROUP BY ACT_Code UNION ALL SELECT ACT_Code , MAX (status_date) AS last_date , 2 AS table_id FROM ASQ_Contact GROUP BY ACT_Code UNION ALL SELECT ACT_Code , MAX (submit_date) AS last_date , 3 AS table_id FROM GR_Authorize GROUP BY ACT_Code ) SELECT ACT_Code , MAX (CASE WHEN table_id = 1 THEN last_date END) AS aiu_updt_date , MAX (CASE WHEN table_id = 2 THEN last_date END) AS ac_status_date , MAX (CASE WHEN table_id = 3 THEN last_date END) AS gr_submit_date FROM union_data GROUP BY ACT_Code ORDER BY ACT_Code ;
Published by: Frank Kulash, on September 16, 2009 15:02
Added UNION-pivot example -
How to erase data from the iphone if I lost and iphone is offline
How to erase data from the iphone if I lost and iphone is offline
< post branched out by host >
Hello
What to do if your iOS device is turned off or offline?
If your missing device is turned off or offline, you can still implement this Mode lost, lockor remote wipe. The next time your device is online, these measures will take effect. If you remove the device from your account while it is offline, pending actions for the device will be cancelled.
If your iPhone, iPad or iPod touch is lost or stolen - Apple supports
-
How to acquire data from the memory of the meter
I am a beginner of Labview. I don't know how to acquire data from the memory of the meter.
I read a few examples of data acquisition, but apparently not similar to my case. I can't use DAQ in my computer, because I don't have DAQ card.
Could someone give me some pointers? Similar examples would be great.
-
How to recover data from the choicefield retained
Hello
How to recover data from the choicefield retained
Thank you
SujithRavindran
getSelectedIndex method will help you.
-
How to transfer data from the 7 Millennium
How to transfer data from the 7 Millennium
You will need to manually back up your files by copying and pasting on a device from external storage such as a USB key or external hard drive.
Then copy them on Windows 7:
-
Is it possible to see/get the data from the table to a dump file
I have files dmp generated using expdp on oracle 11 g...
expdp_schemas_18MAY2013_1.dmp
expdp_schemas_18MAY2013_2.dmp
expdp_schemas_18MAY2013_3.dmp
Can I use a settings file given below to get the data from the table in the file sql or impdp the only option to load the data of table in database.
VI test1.par
USERID = "/ as sysdba".
DIRECTORY = DATA
dumpfile=expdp_schemas_18MAY2013%S.dmp
SCHEMAS = USER1, USER2
LOGFILE = user_dump_data.log
SQLFILE = user_dump_data. SQL
and impdp parfile = test1.par.
No,
DataPump cannot retrieve a dumpfile data in a flat file.
Dean
-
How to share data in the tables ' User_ * ' with another schema
I want to share the data in the table WHERE USER_SEGMENTS with another schema. If I create a view and grant select on the view, when the other schema queries the view data are identical to themselves querying the SYS.user_segments table directly.
My guess is that the SYS.user_segments table is a view based on the current user.create view sys_user_segments as select * from sys.user_segments; grant select on sys_user_segments to A;
Is there a way to share such data without creating a copy of the table?
Oracle: 10g
Thank youIf the ADMINISTRATOR is concerned about B access to DBA_SEGMENTS (or by creating DBA_SEGMENTS views that belongs to a user who has access on top and then grant access to this view of B), it seems pretty crazy allow that kind of database connection.
If you create a database link belonged to B that connects to A, B is, in substance, given any privilege that has exercises. But it is done in a very, very dark which will no doubt be neglected in the future when someone gets a check. He'll be sitting here to wait that someone (accidentally or intentionally) Decides to exploit the security hole and do something that is causing a problem (by removing all data from a table, grabbing all the sensitive data in a table, etc.). Risks of this almost certainly far, far* far * outweigh the risks of even leaving B to obtain direct access to DBA_SEGMENTS.
Justin
-
How to publish data from a table using the form
Oracle forms6i
Hai All
I have download the data to the table of forms...
My table T1 columns are in, out, intrinsically, introut, empname, empno
and another table T2 consist of three columns is empno, date, time
In table T2 time fields consist of symbol I, o... I mean IN, O OUT
My Question is when an employee consist of 3 I - the three IN the time
0815 I, 1200 I, 1415 I and OUT 3 times O 1245, 1445 O, O 1715 and empno is 001
If there is no record for empno 001 then insert first 0815 I in table T1 in column IN time then
to update 1200 intrinsically and 1245 update to Introut and 1415 up-to-date addin and 1445 to update addout
Finally in 1715 to outtime
If it is possible to do without Hardcoding the moment Pls tell with some good example
Thanks in advance
Srikkanth.MThere now things are clear... whenever I have free I'll post the code u how to do this...
for now, a few tips can help u
-create the table to store operations travel so then u can't fix your code
-Create the cursor on the T1 line through all the records.
-Control what empno and action i.e. the current cursor (I or O) exists on the same date in T2 or not
-otherwise exists insert a new record check also the SHIFT is coming in time IF is between MAJ 0815 and 1645 and action is 'I' then insert record and column values accordingly
s ' there is, then update the record of the place where empno = cur.empno and attendance_date = mydate;
It may be useful
Baig,
[My Oracle Blog | http://baigsorcl.blogspot.com/]
Maybe you are looking for
-
How to turn off sync library iCloud?
So I have two libraries with family photos (the default library) and another filled library of art - as in the game video game screenshots etc. It seems that the Art Library downloads thousands of photos on the cloud and they reappear in my main libr
-
Satellite P100 - its becoming distorted / crackling
My sound started to stop and start to deform / crackling.I installed the latest version of the bios and audio drivers, but sound is still the same.Connection to external speakers does not solve the problem either.Can anyone help?
-
Cannot install updates of the Windows platform
Original title: installation window platform update I have upated to service pack 2. But I was able to put this window platform. I click on the update of the registration and it keep showing me the service is not available.
-
RES://ieframe.dll/acr_depnx_error.htm#
RES://ieframe.dll/acr_depnx_error.htm#
-
When I click on the button check printing details and it appears a message saying not able to create Details page.How can I solve this problem? for those who want the truth revealed open their hearts and their secrets unseal right now until the now f