using a Case statement to display the values of column even as table headers
I have a database that has been set up kind of tricky, in that some tables are made up of columns that are field names and one link to another table that contain the data for these field... also names there ID displays as many lines instead of as a row of data. I would like to write a query to extract that information and display it as one line for each ID.
example: table 1
ID, name, itemresponse and itemcode, Description
Dee Jones Childrens Hospital 123 SITE location
123 dee Jones, Date of appointment next NEXTAPPT 22/04/2014
123 dee Jones was on bedrest NOSHOW reason do not show
I would like to have the display of data as a record on this same patient, instead of as 3 separate registers (with the Description column in table 1
Table 2
ID, name, place, Date of the next meeting, show no reason
123 dee Jones Childrens Hospital 22/04/2014 was the bed rest
I have included the code I worked on below my question, for me to get the desired results should I use the Case statement and it's the right way to do it below?
(SELECT
PAT.ID "PATIENT ID."
PAT. FIRST | » '|| PAT. "PATIENT FIRST NAME."
PAT. "PATIENT DOB," DATE_OF_BIRTH
DS. Date 'Date of inpatients ',.
Dai. ITEM_CODE "Item Code",
Dai. DESCRIPTION "Description."
Siad. ITEM_RESPONSE,
Max (CASE WHEN dai. ITEM_CODE IS "SITE" THEN DAI. Decription
ANOTHER NULL
END) AS "name of the hospital."
Max (CASE WHEN DAI.) ITEM_CODE IS 'NEXTAPPT' THEN DAI. ITEM_Description
ANOTHER NULL
END) AS 'next Appt Date. "
Max (CASE WHEN DAI.) ITEM_CODE IS "LASTDATE" THEN DAI. Description
ANOTHER NULL
END) AS 'last visit Date.
Max (CASE WHEN DAI.) ITEM_CODE IS 'NOSHOW' THEN DAI. Description
ANOTHER NULL
END) THAT "the reason has not shown".
Of
(PAT.ID "IDENTIFYING PATIENT",
PAT. FIRST | » '|| PAT. "PATIENT FIRST NAME."
PAT. "PATIENT DOB," DATE_OF_BIRTH
DS. Date 'Date of inpatients ',.
Dai. ITEM_CODE "Item Code",
Dai. DESCRIPTION "Description."
Siad. ITEM_RESPONSE
Of
dm_sessions Ds,
dm_session_assessments dsa,
DAS dm_admin_sections,
dm_session_assessment_items Siad,
Dai dm_admin_items,
Po Patient_Orders,
Inventory inv,
Patients_Table PAT
dm_admin_categories CAD
where dsa.session_Id = ds.session_Id
and PAT.ID = ds. Patient_ID
and dsa.excluded_assessment =' no
and dac.category_code = 'OPEN'
and dsa.section_id = das.section_id
and das.category_id = dac.category_id
and das.section_code = 'northwest'
and dai.section_id = das.section_id
and dsai.item_id = dai.item_id
and dsai.session_assessment_Id = dsa.session_assessment_Id
and dsai.excluded =' no
- and Dai.ITEM_ID = Dsai.ITEM_ID
and Dai.ITEM_CODE IN ('SITE', 'NEXTAPPT', 'LASTDATE', 'NOSHOW')
and po.patient_ID = ds.patient_ID
and in. NDC_NO = inv. NDC_NO
and inv. TDRUG_ABBREV = in. DRUG_ABBREV
PAT.ID GROUP, PAT. FIRST | » '|| PAT. LAST, PAT. DATE_OF_BIRTH, ds. Date, dai. ITEM_CODE, dai. DESCRIPTION, Siad. ITEM_RESPONSE))
Hello
DATE is not a very good name for a column. Use something like EVENT_DATE, that will not be confused with a keyword from Oracle, instead.
I don't see something like this column in the CREATE TABLE statement. He will always be the same value on all lines?
Here's a way to get the results you requested:
SELECT id
first name | ' ' || LastName AS name
Date of birth
MAX (CASE WHEN item_code = "NEXTAPPT", THEN item_response END) AS next_appointment,
MAX (CASE WHEN item_code = "LASTDATE" THEN item_response END) AS last_visit_date,
MAX (CASE WHEN item_code = "SITE" THEN item_response END) AS location
FROM mytable1
GROUP BY id, firstname, lastname, dob
;
Of course, I can't test it very well until you post INSERT statements for the sample data.
I guess that 2 or more lines of the entry have the same id, then they will necessarily be first name last name, the name and date of birth, too. No doubt they are standardized in your actual tables.
Tags: Database
Similar Questions
-
How to display the value of the column
Oracle 10g on Linux
I want to display the value of the id column in the table of www if count (distinct id) is 1. The following query is fine except that it does not display the value of the column ID help, please.
SELECT count(distinct id) FROM www c WHERE C.x_code IN (SELECT D.x_code FROM www_app d WHERE d.y_code = '1151299386') having count(distinct id) = 1
I think you can use MAX in this case
SELECT max(id) FROM www c WHERE C.x_code IN (SELECT D.x_code FROM www_app d WHERE d.y_code = '1151299386') having count(distinct id) = 1
-
How to display the value of the variable for bottom of pl/sql
How to display the value of the variable for bottom of pl/sql
declare
V_1 number: = 10;
V_2 number: = 20;
V_3 number: = 30;
v_4 number: = 40;
v_5 number: = 50;
test varchar2 (100);
Start
I'm in 1.5
loop
test: = "v_" | I have;
dbms_output.put_line(i||) e > ' | test);
end loop;
end;
/
How to get below output:
1 > v_1
2 > v_2
3 > v_3
4 > v_4
5 > v_5
But I want to output of
1 > 10
2 > 20
3 > 30
4 > 40
5 > 50
Hello
You cannot reference variables as you did and get the value of the variable. Use pretty collection.
set serveroutput on size 2000 declare type number_table is table of number; numbers number_table := number_table(10, 20, 30, 40, 50); begin for i in numbers.first .. numbers.last loop dbms_output.put_line(i || '->' || numbers(i)); end loop; end; / anonymous block completed 1->10 2->20 3->30 4->40 5->50
See the Collections of PL/SQL and Records http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#LNPLS005
-
Display the values of the Page element in HTML table
Hi all
could you please help me with the below? I want to have a table in the HTML area and to display in the table of elements of the Page of the page.
I got the code like this:
{
< table >
< tr > < td > & P1_ECEMEA_ASSISTANCE < table > < /tr >
< tr > < td > & P1_ECEMEA_WIP < table > < /tr >
< /table >
}
It shows the element of the Page names in the form of text, not the values.
However, this code without the tags table:
{
ECEMEA request for Assistance of the CQT: & P1_ECEMEA_ASSISTANCE.
ECEMEA CQT Work in Progress: & P1_ECEMEA_WIP.
}
Works and Page element values are displayed.
Is it possible to display the values of the Page element in the HTML table at all or should I use a different method to show the values in a table? The above is only an excerpt of the code. I need to display about 30 items in Page, put in shape in a table with headers.
Please let me know what kind of region is the best to use, or if I have to use only a few symbols of escape in the table code...
Thank you and best regards,
VladimirVladimir,
Looks like you're missing the period after the substitution variables.
{
&P1_ECEMEA_ASSISTANCE. &P1_ECEMEA_WIP. -D.
-
Javascript-based dynamic action and display the value of (!) from the selection list
Hello
I'm not a jQuery guru (yet).
Can someone show me how to turn on or off an ITEM on a form based on the value display of a selection list (usually I have dynamic lists, so I don't 'know' even internal values)
I created a simple demo in which you can (if you want to) show me how it works.
Workspace: 6POOLRULES
User: demo01
Password: demo
Application: 30851 (Drone)
The idea is to
* Disable/hide the "Id other Description" If the ' Id Type (display value!) is 'Passport' or 'license '.
* activate/display the Description of the 'other' Id if the ' Id Type (display value!) is "other".
I think that it should be dynamic action based on javascript/jQuery. But what would this jQuery selector should look like?
Published by: bveoracle on March 29, 2012 07:28
Published by: bveoracle on March 29, 2012 07:30Hello
OK, I changed the dynamic action to use Jquery and get text from the value. The only thing I changed is in the section WHEN.
Enjoy.
-
Display the values of variables
I'm working on a Captivate 5 project in which the values of the variables are assigned and then reassigned. Is it possible to display the value of a variable in a text box or other window to ensure that the value changes? Thank you.
Darin
Hello David,.
It's the way I am especially debugging advanced actions by inserting the variables used in a text of the legend Rick indicates. A long time ago that I wrote two articles on the basic use of variables, perhaps reading could specify:
Use the power of variables without advanced actions
Unleash the power of variables with advanced actions
CAUTION: sometimes the update does not appear immediately. In another thread, I explained how you can refresh the contents of the enhanced TextArea widget that contains a variable that is filled with another widget on the same blade.
Lilybiri
-
The first query shows that there is no amount present in the warehouse
The second query shows the warehouse got about 35 pieces of a specific material.SQL> select sum(received_qty) - sum(transact_qty) - sum(transit_qty) from ship_1 where matid='52616 ' and placefrom='Jeddah MC'; SUM(RECEIVED_QTY)-SUM(TRANSACT_QTY)-SUM(TRANSIT_QTY) ----------------------------------------------------
In the form for the first query, I want to display the value 0 (zero), how this can be done...?SQL> select sum(received_qty) - sum(transact_qty) - sum(transit_qty) from ship_1 where matid='8521' and placefrom='Central Store'; SUM(RECEIVED_QTY)-SUM(TRANSACT_QTY)-SUM(TRANSIT_QTY) ---------------------------------------------------- 35
Hello
Using NVL as
select NVL (sum(received_qty) ,0) - NVL (sum(transact_qty),0) - NVL (sum(transit_qty),0) from ship_1 where matid='52616 ' and placefrom='Jeddah MC';
Kind regards
Abdetu...
-
Why HBox does not display the value of the label?
I try to display the value of language in HBox (red cloth).
< mx:HBox label = "Tax Code" width = "100 percent" height = "100%" >
< mx:VBox autoLayout = "true" >
< mx:HBox label = "tax detailsborderStyle""" = "solid" borderColor = "#000000" ToolTip = "Tax Details" textAlign = "center" > "
< mx:Form width = "100%" height = "90%" >
< mx:FormItem label = tax "Registered(Y/N)" direction = "horizontal" >
< mx:RadioButtonGroup id = "rbgCreditTaxDetails" / >
< mx:RadioButton label = "Yes" groupName = "rbgCreditTaxDetails" / >
< mx:RadioButton label = "" groupName = "rbgCreditTaxDetails" / >
< / mx:FormItem >
< mx:DataGrid dataProvider = "{status}" >
< mx:columns >
< mx:DataGridColumn headerText = "TaxCode" dataField = "status" / >
< mx:DataGridColumn headerText = "tax registration No." dataField = "description" / >
< / mx:columns >
< / mx:DataGrid >
< / mx:Form >
< / mx:HBox >
< / mx:VBox >
< / mx:HBox >
Hello
This tag will be useful when you add your HBox in a TabNavigator. In tabs label will indicate.
Hope this helps
Rush me
-
How to display the values of the Parent form in the form of child
Hello
I have the order Page and Page element
In the order Page If I select any item and click submit, it should open the article Page and results should display in advance table region. In my article page I have region of header (default double) with 3 fields (dummy) as
Agenda
Description
org
Now my question is, I need to display the value of the item in the item Page header area in the column of the item that I was selecting in the order Page.
I have a prescription 100 point A, B, C, I select B and click on submit it should open on the Articles page and article Page, I have a column called Item and value B sholud be fulfilled.
Thank you
MaheshOAMessageTextInputBean oa = (OAMessageTextInputBean) webBean.findChildRecursive ("ItemNo");
oa.setAttributeValue (SItemNo);There is no such method as setAttributeValue for UI beans, this method is for VO, that is to say if you take a VO and VO a method object to set its attribute.
Bean of the user interface, you will need to use method below,
OAMessageTextInputBean oa = (OAMessageTextInputBean)webBean.findChildRecursive("ItemNo"); oa.setValue(pageContext,SItemNo);
Thank you
AJ -
Display the value of the element in the HTML area
Is there a way to display the value of an element within an HTML reigion? I know below is not the syntax that is appropriate, but there must be a way to call for the value of an element to display in my HTML code.
<!--
< body >
< p >: P1_ITEM < /p >
< / body >
->
Published by: dsn0wman on August 31, 2008 12:58
Published by: dsn0wman on August 31, 2008 12:59You can use the following syntax in the header, html body, or the footor in your area:
& P1_ITEM.
And commercial front and end point are needed.
If you want to format, you can use the following
< span style = "make-weight: bold;" "color: darkblue" > & P1_ITEM. </span >
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
------------------------------------------------------------------- -
Display the values in a list in a certain way
Hello
I'm looking for a way to display the values in a list by the first value by a slash and the rest with an indentation.
In other words in this way:
/value
Value1
value2
value3
etc...
Please see the attachment for a better reference where data are received and then filled to the window list.
Thanks for your comments
Thanks guys,.
I endend up doing this:
If (i == 0)
{
sprintf (current_log_view, "/ %s", cnfg_display_db [i] "");
}
on the other
{
sprintf (current_log_view, "%s", cnfg_display_db [i]);
}
SetCtrlVal (log_panel, LOG_LOG_TB, cnfg_display_db [i]);
InsertListItem (dir_list_panel, DIR_LIST_RETR_LIST, current_log_view, i, 0);and it works very well!
Thanks again
-
Which of the 2 hlp files should I use in Win7/64 to display the types of old
Which of the 2 hlp files should I use in Win7/64 to display the types of old
Windows6. 1 x-KB917607-64.msu or
. Msu Windows6. 1 - KB917607 - x 86 (1)
Hello
You must install the package Windows6. 1-KB917607-x 64.msu scored since you are on a 64-bit computer. Hitting the green button to continue on the right side to start the download and installation.
-
Need help displaying the value of field in another!
I have a problem, I'm sure is simple but I can't understand it.
I would like to create a field that displays the value of a field point selecteed in drop down. For example, I created a drop down menu which has 3 times that I have assigned values to each:
Items in drop-down list
point: Unlimited time export assigned value: 4 000,00
point: 8-hours coverage export value assigned: 3,000.00
point: 5 hours Covrage export value assigned: 2,000.00
This drop-down list is named "CoverageTime".
I want to create a text called 'Price' field that will display the value of the selected 'CoverageTime' element drop-down list.
For example, if I chose "Unlimited" (which I have highlighted as 4,000.00) in the drop-down list, the 'Price' of text field should display the value of 'CoverageTime' of 4 000,00.
As you can see in my screenshot, I have selected ' Unlimted Time'. The value that I put to this element from the drop-down list is 4,000.00. But the price text field does not the value of the element "Unlimited time", selected in the drop-down list.
How to make this happen? (Sorry for the picture on the side)
I'm not sure what you mean about #1 (there is nowhere where to put the code in the tab Options), but it's okay because the second is on the right track. But to set the value of the field, assign anything you want event.value. So the correct code for the custom script to calculate the price of the text field:
The value of this field for the price of the value selected from the drop-down list
Event.Value = getField("CoverageTime").value;
-
Display the value in the selection list
Hi all
Any body know how to get the text to display selection list in another text field? Suite of java script displays the value no text, I need another way around. I don't want to change the selection list that the user needs to see the text value.
in the HTML section.
< script language = "JavaScript" type = "text/javascript" >
int f_getText (pThis, pThat) {}
var enter_val = pThis;
var return_val = pThat;
{
gReturn = document.getElementById ("enter_val") .value;
{html_GetElement (return_val) .value = gReturn.toUpperCase ()}
}
}
< /script >
>
in the HTML form element attributes.
onBlur = "javascript:f_getText('P40_LOC_ID','P40_LOCATION')";
"" Thank you
Pascal MChange your JS function
function f_getText (pThis, pThat){ var sel=$x(pThis); $x(pThat).value= sel.options[sel.selectedIndex].text }
CITY
Published by: city has 8 November 2008 17:24
-
change the color of line based on the value of column 5 Apex in the classic report
Version of the apex 5.0.0.00.31
Standard universal theme
Page theme default template
Classic report
Foldable report template
Hello
I know this question has been asked several times here, but I'm working on 5 Apex and need to know the correct way to do it in this version.
I need to change the color of the text of the entire line (no background color) based on the value in one of the columns of the classic report. I have just two conditions, if the value of column = Yes, color should be red, otherwise it must be green.
I am new to jscript and css, so appreciate if someone can tell me the solution with steps.
I have already checked this link that changes the value of the column, need to do something similar to the whole line.
https://tylermuth.WordPress.com/2007/12/01/conditional-column-formatting-in-apex/
Hi coolmaddy007-Oracle,.
Here's an example set up on the apex.oracle.com according to the specifications you gave: https://apex.oracle.com/pls/apex/f?p=35467:1
Version of the apex 5.0.0.00.31
Standard universal theme
Page theme default template
Classic report
Foldable report template
Here is how it is done:
Create a dynamic action with the following specifications:
Name: Give the appropriate name
Event: After refresh
Selection type: region
Region: select your region classic report
Condition: No strings attached
Action: Run the JavaScript Code
Fire on loading the Page: Yes
Code:
$('td[headers="JOB"]').each(function() { if ( $(this).text() === 'MANAGER' ) { $(this).closest('tr').find('td').css({"color":"red"}); } if ( $(this).text() === 'SALESMAN' ) { $(this).closest('tr').find('td').css({"color":"green"}); } if ( $(this).text() === 'CLERK' ) { $(this).closest('tr').find('td').css({"color":"blue"}); } });
NOTE: Download the selector appropriate for your knowledge $('td[headers="JOB"]') case using firebug/browser development tools.
Items concerned: leave blank.
PS: Changed the example to change the color of text instead of the background color.
I hope this helps!
Kind regards
Kiran
Maybe you are looking for
-
How can iPhone 5 s, I get my contacts back after inadvertently sent to iCloud?
How can iPhone 5 s, I get my contacts back after inadvertently sent to iCloud?
-
Update to iTunes 12.4 freezes to halfway
According to the subject line... I tried to update my iTunes to version 12.4, but it won't get past 85.9 MB. Here is a screenshot: I have a MacBook Pro 2.5 GHz Intel Core i7, bought in September 2015 15 ". I can't suspend or cancel the update, and of
-
10.6.8 PowerMac G5 Mac wake after sleep
10.6.8 PowerMac G5 Mac wake after sleep
-
Is there a list of available shortcut keys?
Does anyone have a list of the keyboard shortcuts for Firefox for desktop PC?
-
I hate this thing. Sometimes, it records very well and videos open and record very well. high quality image and sound. other times, the own can't opn files. computer says it can't read the file. using playback open the icon is a "?" mark and does not