The value of name of column
Hi gurus
I'm stuck on 1 Scenario and need your help. I have the following table:
Create table
drop table age_rate;
CREATE TABLE age_rate
(
age_0_4 number 4,
age_5_20 number 4,
age_21_34 number 4,
age_35_44 number 4
);
-------------------------------
Insertion
INSERT INTO age_rate
SELECT 45, 50, 60, 90 double UNION ALL
SELECT 45, 50, 60, 88 OF double UNION ALL
SELECT the 40, 50, 60, 90 double UNION ALL
SELECT 5, 50, 60 and 88 DOUBLE;
-------------------------------
Query on table
SELECT * from age_rate;
The query result
age_0_4 age_5_20 age_21_34 age_35_44
45 50 60 90
45 50 60 88
40 50 60 90
5 50 60 88
Power required
Rate Min_age Max_age
-The lower is age band 0_4
45 0 4
45 0 4
40 0 4
5 0 4
-The lower is age band 5_20
50 5 20
50 5 20
50 5 20
50 5 20
-The lower is age band 21_34
60 21 34
60 21 34
60 21 34
60 21 34
-The lower is age band 35_44
90 35 44
88 35 44
90 35 44
88 35 44
Rules
-I have all the data in the rows each column online create separate lines and add 2 columns automatically Min_age and Max_age and insert the value on these columns based on the name of the column for example if the column name as age_0_4 then insert 0 in min_age and 4 in max_age means values for Min_age and Max_age extracted from the base of the column name. I don't know if it's possible or not, but I appreciate if someone can give me the solution for this problem... Do you like answers. Thank you
Hello
I'm not 100% sure what you want. Do you want 16 production lines at a time, which is 4 lines of output for each line that is actually in the table?
This looks like a job for the UNPIVOT operator:
SELECTION rate
min_age
Case min_age
WHEN 0 THEN 4
WHEN 5 THEN 20
WHEN 21 AND 34
WHEN 35 THEN 44
END AS max_age
Of age_rate
UNPIVOT (rate
FOR min_age IN (age_0_4 0)
age_5_20 AS 5
age_21_34 AS 21
age_35_44 AS 35
)
)
ORDER BY min_age
;
Tags: Database
Similar Questions
-
The value of xml type column in oracle database 11 g 2
I have a table containing columns XMLtype as 'XML_TABLE (ID NUMBER, donnees_xml XMlTYPE).
Then I insert a value such as
INSERT INTO xml_table (1, XMLtype('<current> <city id="2643743" name="London"> <coord lon="-0.13" lat="51.51"/> <country>GB</country> <sun rise="2015-03-04T06:38:20" set="2015-03-04T17:46:01"/> </city> <temperature value="280.71" min="280.15" max="281.15" unit="kelvin"/> <humidity value="77" unit="%"/> <pressure value="1029" unit="hPa"/> </current>'));
Now, I want to ask about this table. I can easily choose 'country' with the following query
select t.xml_data.extract('/current/city/country/text()').getStringVal() "XML Data" from xml_table t;
But I can't select the value of the temperature by this query. Now how to select the value of the temperature of the table?
EXTRACT, EXTRACTVALUE etc are deprecated in 11.2.
Use instead the XQuery functions.
If you need to retrieve several values, XMLTABLE will be good:
SQL> alter session set nls_numeric_characters = ".,"; Session altered. SQL> SQL> select x.* 2 from xml_table t 3 , xmltable( 4 '/current' 5 passing t.xml_data 6 columns country varchar2(10) path 'city/country' 7 , temperature number path 'temperature/@value' 8 ) x 9 ; COUNTRY TEMPERATURE ---------- ----------- GB 280.71
-
Divide the values of a single column into multiple values of columns
I want that the values of the "col_val" column to divide into several values in the column
Table1:
Col_val Col1, Col2
Code1 POINT 45
L2 AB 45
L1 POINT 45 OF
Code2 CAB 61
ABC 51 LABORATORY
SSS LAB 45
QQQ BED 123
BBV COT 100
FFF COT 444
Output as expected:
OUT1 out2 out3-out4, out5
Code1 AB SSS
L1
Code2
ABC
QQQ
BBV
FFF
Each line must contain the values corresponding to the Col2 values and each column must have the values in Col1, as illustrated above.
SQL> with t 2 as 3 ( 4 select 'Code1' col_val, 'ITEM' col1, 45 col2 5 from dual 6 union all 7 select 'L2' col_val, 'AB' col1, 45 col2 8 from dual 9 union all 10 select 'L1' col_val, 'ITEM' col1, 45 col2 11 from dual 12 union all 13 select 'Code2' col_val, 'CAB' col1, 61 col2 14 from dual 15 union all 16 select 'ABC' col_val, 'LAB' col1, 51 col2 17 from dual 18 union all 19 select 'SSS' col_val, 'LAB' col1, 45 col2 20 from dual 21 union all 22 select 'QQQ' col_val, 'COT' col1, 123 col2 23 from dual 24 union all 25 select 'BBV' col_val, 'COT' col1, 100 col2 26 from dual 27 union all 28 select 'FFF' col_val, 'COT' col1, 444 col2 29 from dual 30 ) 31 select max(col1) 32 , max(col2) 33 , max(col3) 34 , max(col4) 35 , max(col5) 36 from ( 37 select decode(col1, 'ITEM', col_val) col1 38 , decode(col1, 'AB' , col_val) col2 39 , decode(col1, 'LAB' , col_val) col3 40 , decode(col1, 'CAB' , col_val) col4 41 , decode(col1, 'COT' , col_val) col5 42 , t.col2 col_2 43 , row_number() over(partition by col2, col1 order by 1) rno 44 from t 45 ) 46 group 47 by col_2, rno 48 order 49 by col_2; MAX(C MAX(C MAX(C MAX(C MAX(C ----- ----- ----- ----- ----- Code1 L2 SSS L1 ABC Code2 BBV QQQ FFF 7 rows selected. SQL>
-
Web Forms: Deleting line based on the value of a specific column
Hello
I have an online form in which I want to apply delete missing on the ranks, but only on the value of the first column. So, if the first column is #missing I want the deleted row, even if the columns are given in it.
Is it possible to do this?
I'm on ver 11.1.2.2 Hyperion Planning
Shehzad
Published by: shehzad k on January 24, 2013 11:51Unfortunately, no. There is no way to add the delete line based SOLELY on the existence of a value in the first column. It would be nice to see some of the more advanced features "conditional delete", we en flies over to the planning of the entry forms.
You can do the "clumsy" things with data validations where you gray - out ranks in view of the existence of a value in a particular cell, however while this might SUGGEST that the user should not enter data in a particular line, it would not PREVENT to do so.
We have seen many improvements in form lately with the introduction of data validations. I hope the momentum continues.
-Jake
-
What SYS (or tables) store the value of a spec /not/ NULL columns? (It doesn't seem to be COL$)
NOTE: This is NOT a trick question - although it seems to be.
Test configuration:
Test configuration:BANNER Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production
1. a table is created by SCOTT in the SCOTT schema with a NULLABLE column.
2. a primary key constraint is added using only the NULLABLE column
3. Requests for information on USER_TAB_COLS, ALL_TAB_COLS, DBA_TAB_COLS and SYS. COL$ see NOT NULL for the column NULLABLE
as necessary for a primary key constraint. Views derive their data from the column of $ NULL the sys. Table of $ COL
using
and the table of $ COL shows a numerical value of '0' before you add the primary key and a value of "1" later.'DECODE (SIGN (c.null$), -1, 'D', 0, 'Y', 'N'),
4. a query on the DDL metadata table shows the specification for column NULLABLE of origin involved.
Question - where this original specification NULLABLE is stored?
This question is based on a question asked by another user in this thread
Columns becoming nullable after a fall of primary key?
I created the following specially for that matter test case
The DOF shows that Oracle keeps the original spec NULLABLE for the column and uses it to generate the DDL orginal, even if there is a primary key on the table and the system views (and COL$) show the column non NULLABLE.-- scott ensures table does not exist DROP TABLE tbl_test CASCADE CONSTRAINTS; -- scott creates a table CREATE TABLE tbl_test ( col_1 NUMBER, col_2 NUMBER NOT NULL); -- scott queries to check the the column nullable status SELECT table_name, column_name, nullable FROM user_tab_cols WHERE table_name = 'TBL_TEST'; -- TABLE_NAME | COLUMN_NAME | NULLABLE -- TBL_TEST | COL_1 | Y -- TBL_TEST | COL_2 | N -- Scott addes a primary key constraint using only the nullable column ALTER TABLE tbl_test ADD CONSTRAINT tbl_test_pk PRIMARY KEY(col_1); -- scott queries to check the the column nullable status SELECT table_name, column_name, nullable FROM user_tab_cols WHERE table_name = 'TBL_TEST'; TABLE_NAME,COLUMN_NAME,NULLABLE TBL_TEST,COL_1,N TBL_TEST,COL_2,N -- scott queries to get the table DDL select dbms_metadata.get_ddl('TABLE', 'TBL_TEST', 'SCOTT') FROM DUAL; DBMS_METADATA.GET_DDL('TABLE','TBL_TEST','SCOTT') CREATE TABLE "SCOTT"."TBL_TEST" ( "COL_1" NUMBER, <------ where is this NULLABLE spec stored? "COL_2" NUMBER NOT NULL ENABLE, CONSTRAINT "TBL_TEST_PK" PRIMARY KEY ("COL_1") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS NOCOMPRESS LOGGING TABLESPACE "USERS" ENABLE ) SEGMENT CREATION DEFERRED PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING TABLESPACE "USERS"
So where is the original information NULLABLE actually stored?rp0428 wrote:
What SYS (or tables) store the value of a spec /not/ NULL columns? (It doesn't seem to be COL$)I think that it becomes a bit messy depending on order of activity:
You can see Col. .null$ is set to a non-zero when the desrcibe command displays the column as not null, but it can happen for two reasons:
(a) user sets the column as not null - in which case you get a line in cdef$ with type # = 7
(b) the user adds a primary key to table - in which case you get a line in cdef$ with type # = 2If you declare null AND add a primary key, you get two lines - that's why it is possible for Oracle to determine if he should remove the flag not null when you remove the primary key and also allows dbms_metadata show the create statement of table without a NOT NULL even when describe it the watch with a NOT NULL - dbms_metadata can respond to the presence of the type # = 2 and absence of the type # = 7.
Concerning
Jonathan LewisBy the way: by a strange coincidence, it seems to me answering the previous post, three days before it was asked: http://jonathanlewis.wordpress.com/2012/04/19/drop-constraint/#comment-46140 (on the doubts, this isn't - it answers a different question on the removal of constraints).
Published by: Jonathan Lewis April 23, 2012 11:07
-
Add up the values from two numeric columns on RTF model
Hello
I'm trying to add up the values of the numeric column 2.
I tried..? column_1 and column_2? > but it's not as simple as that obviously I get an error when you try to do
I tried..? sum (current - group () / column_1) + sum (current - group () / column_2)? >, but who does no more work that it also returns an error
Any ideas how to add two numeric columns in RTF model?for 2 + 3
-
Need help with Javascript to get the value of standard report column
Hi all
Apex 3.1 version
I have a query SQL (editable report) region where I need to do validations using a process of OnDemand and javascript. For this posting, I need to use the serial number and id of this same report line item. The function is called when the serial number is changed. I can get the serial number easily because it is a text field, however, the item id is a standard report column (which actually a text field or hidden gives me a checksum error, long story). How can I get the value of the standard report column to set the value of an element of the Application to use in my process of application as well as the serial number? Here is my code below.
<script> function f_ValidateSerial(pThis) { // The row in the table var vRow = pThis.id.substr(pThis.id.indexOf('_')+1); //alert('Row is '+vRow); // Display the serial number //alert('The Serial Number is '+html_GetElement('f21_'+vRow).value); var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=ValidateSerial',0); get.add('F101_SERIAL_NUMBER',html_GetElement('f21_'+vRow).value); get.add('F101_INVENTORY_ITEM_ID',+html_GetElement(?????+vRow).value); // Here's where I need to get the item id to set application item!! gReturn = get.get(); if (gReturn) { alert(gReturn); } if(gReturn) { html_GetElement('f21_'+vRow).value = ''; } } </script>
Hello
Ok
Item ID is standard report column.
If you enter this Expression HTML column#ITEM_ID#
I guess that the substitution of column item Id is #ITEM_ID #.
Now, you have hidden input form that is not submitted.
Then in JavaScriptget.add('F101_INVENTORY_ITEM_ID',+html_GetElement('item_id_'+Number(vRow)).value);
Kind regards
Jari -
find the value relative to another column
Find the value column B in the column 'sparent. Let me explain the few cases:
Suppose that we receive the 1000 kg of quantity for Jack, Jack then transferred this 1000 kg to Robin and Robin transferred once again this amount to Parkins and so on. A column named Type records the entry type, either it's a receipt or transfer operation. His entry would be recorded in my table like:
QTY_ A_ B_ Type_
Reception of 1000 Jack
1000 jack Robin transfer
Transfer of 1000 Robin Parkins
So, with this information, you find the parent of Parkins, Jack, receipt of Type?with t as (select 1000 qty,null a,'jack' b,'receipt' type from dual union all select 1000,'jack','robin','transfer' from dual union all select 1000,'robin','','transfer' from dual union all select 1000,'parkins','jack','transfer' from dual) select * from t where connect_by_isleaf = 1 and a is null connect by nocycle b = prior a start with b = 'jack' ; QTY A B TYPE ---------- ------- ----- -------- 1000 jack receipt 1 row selected.
Good bye
DPT -
ALTER Table of the default Oracle and the length of name of column Type
Hi all
I want to increase the length of the table names and the names of the columns in Oracle.
By default, it is set like this:
SQL > dba_tab_columns desc;
TABLE_NAME NOT NULL VARCHAR2 (30)
COLUMN_NAME NOT NULL VARCHAR2 (30)
...
Is it possible to change the VARCHAR2 (30) to VARCHAR2 (100)?
Published by: sukrandere on 12:21 10.Mar.2010Table names and column are all two identifiers
According to the documentation, the maximum length of an identifier is 30 characters.
It is hard coded in the database software and you can't change it.
Or do you need to change.---------------
Sybrand Bakker
Senior Oracle DBA -
How to get the value of a particular column column name?
Hi all
How to get the column name for a particular column value.
example:
create table test (ID number, col2, col3 varchar varchar);
Insert into test values (1, 'true', 'false');
Insert into test values (2, 'false', 'true');
commit;
I want to choose the name of the data column 'true' with id = 1;
That is to say) while waiting for answer is "col2". pls help someone.This might help:
DECLARE c1 SYS_REFCURSOR; BEGIN OPEN c1 FOR SELECT col2, col3 FROM test WHERE id = 1; -- FOR c IN (SELECT rownum rn, t2.column_value.getrootelement() name, EXTRACTVALUE(t2.column_value, 'node()') value FROM TABLE(XMLSEQUENCE(c1)) t, TABLE(XMLSEQUENCE(EXTRACT(column_value, '/ROW/node()'))) t2) LOOP IF c.value = 'true' THEN DBMS_OUTPUT.PUT_LINE(c.name); END IF; END LOOP; END;
-
How to find the value duplicate of each column.
I have it here are four columns,
How can I find the duplicate of each columns value.
with All_files like)
Select ' 1000 'like BILL, "2000" AS DELIVERYNOTE, CANDELINVOICE ' 3000', '4000' CANDELIVERYNOTE of all union double
Select ' 5000 ', ' 6000', ' 7000 ', ' 8000' Union double all the
Select '9000 ', '1000', '1100',' 1200' from dual union all
Select ' 1200 ', ' 3400', ' 6700 ', ' 8790' Union double all the
Select ' 1000 ', ' 2000', ' 3000 ', ' 9000' Union double all the
Select '1230', '2340', ' 3450 ', ' 4560' double
)
SELECT * from All_files
Output should be as shown below.
1000 2000 3000 4000
9000 1000 1100 1200
1200 3400 6700 8790
1000 2000 3000 9000
Required to check uniqueness columns.
Thank you.Hello
If you are not too concerned about performance, this should give you the desired result:
SELECT distinct INVOICE, DELIVERYNOTE, CANDELINVOICE, CANDELIVERYNOTE FROM ( SELECT a.*, count(*) over(partition by t.column_value) cnt FROM All_files a, table( sys.odcivarchar2list( a.INVOICE , a.DELIVERYNOTE , a.CANDELINVOICE , a.CANDELIVERYNOTE ) ) t ) WHERE cnt > 1 ;
-
I have been using Outlook for awhile now. I stayed at thunderbird recently. I feel good. However, I would like to know how to set the column first as the column message sender. I don't know that there should be a way to customize that? Help the mozilla team. Thank you, haris
The buttons of the column can be moved in any order by drag-and - drop. Right click on a button in the column to select the columns to display.
-
Contact form sends only the values of name
Hi all
I haven't posted for awhile to try to learn php at this point, but became very stuck for more than two weeks now, and for the life of me, I can't seem to fix my problem.
I finished a script tutorial on how to create a form of contact php, but when I fill the form and send it, the form stores any information typed because instead, I get the following message:
: Name
E-mail: E-mail
Comments: comments
That's exactly what I get every time and I can't find a solution, I tried reading online resources and through the books I have, but I can not find the reason why, anyone who has ever met this before or have a link they could post.
Note for this is when I click on the reply button, it will let respond me to the correct e-mail which was presented in the form, but the email field looks like I typed it above.
Any help would be much appreciated.
Greetings from King,
Pete
Thanks for your reply, but in the meantime, I found my mistake, in a variable variable that I forgot an additional sign of $ I can't believe I missed that for days, all learning I guess.
Thanks again Ben for your answer
Kind regards
Pete
-
Calculate the difference based on the values of 2 different columns
Hello friends,
I basically want to do something like below that is the Format t - SQL:
SUM (CASE column WHERE 'ABC' THEN 1 ELSE 0 END)-SUM (CASE columnB WHERE 'XYZ' THEN 1 ELSE 0 END)
For which I was changing the following code in Oracle:
SUM (CASE column = 'ABC' THEN 1 ELSE 0 END)-SUM (CASE columnB = END ELSE 0 'XYZ', 1).
But his failure to validation with an error message - missing right parenthesis...
Rest of the qry is very good, and each time I have add this line it starts failing.
Published by: Sweta on 11-Sep-2009 09:32Try this
SUM (CASE WHEN columna = 'ABC' THEN 1 ELSE 0 END) - SUM (CASE WHEN columnb = 'XYZ' THEN 1 ELSE 0 END)
or
COUNT (CASE WHEN columna = 'ABC' THEN 1 END) - COUNT (CASE WHEN columnb = 'XYZ' THEN 1 END)
Note: you can use this sythax in oracle
SUM(CASE columnA WHEN 'ABC' THEN 1 ELSE 0 END) - SUM(CASE columnB WHEN 'XYZ' THEN 1 ELSE 0 END)
Example of
SELECT emp_test.*,CASE ename WHEN 'SCOTT' THEN 1 END ind FROM emp_test EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO IND ---------- ---------- --------- ---------- ---------- ---------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 1980-12-17 800 20 7499 ALLEN SALESMAN 7698 1981-02-20 1600 300 30 7521 WARD SALESMAN 7698 1981-02-22 1250 500 30 7566 JONES MANAGER 7839 1981-04-02 2975 20 7654 MARTIN SALESMAN 7698 1981-09-28 1250 1400 30 7698 BLAKE MANAGER 7839 1981-05-01 2850 30 7782 CLARK MANAGER 7839 1981-06-09 2450 10 7788 SCOTT ANALYST 7566 1987-04-19 3000 20 1 7839 KING PRESIDENT 1981-11-17 5000 0 10 7844 TURNER SALESMAN 7698 1981-09-08 1500 30 7876 ADAMS CLERK 7788 1987-05-23 1100 20 7900 JAMES CLERK 7698 1981-12-03 950 30 7902 FORD ANALYST 7566 1981-12-03 3000 20 7934 MILLER CLERK 7782 1982-01-23 1300 10 14 rows selected.
-
concatenation error - when I use the value of the column of text in which the condition.
Hello
I'm creating Materialized view using a few columns from two tables and by obligation, I need to prepare a select statement with a where condition in another column. (new heading)
I tried like below...
create a materialized view HAND
force refresh on demand
as
Select
a.table_name,
a.column_name,
b.trial_name,
' Select * from ' | '. a.table_name |' where ' | a.column_name | ' = '|| b.trial_name | « ; » "QUERY".
Of
exp_csv_tB has,
b exp_csv_tr;
the value of name a.table is: monitoring_table
a.column_name value is: study
b.trial_name = fty777
Materialized view created with an extra column, but it is not added "(codes) to the value of the text in which the condition.
output I got is:
Select * from monitoring_table where study = fty777;
but
I need output like
Select * from monitoring_table where to study = "fty777";
value of fty777 must be in the codes like "fty777". I read a few articles, but did not get this example.
Help, please.You need to escape your quotes (double upward on quote)
create materialized view MAIN refresh force on demand as select a.table_name, a.column_name, b.trial_name, 'select * from '||a.table_name||' where '||a.column_name|| ' = '''|| b.trial_name||''';' "QUERY" from exp_csv_tB a, exp_csv_tr b;
Maybe you are looking for
-
I would like to transfer my Yahoo to Firefox favorites. How can I do this?
I would like to transfer all my favorites from Yahoo to Firefox. How can I do this?
-
Motorola i1 - default theme change?
I HAVE A MOTOROLA I1 AND I WOULD LIKE TO ADD MORE SCREENS TO MY THEME OF THE DEFAULT VALUE IS 3 SCREENS, I WANT TO BE ABLE TO ADD, BUT KEEPING THE SAME THEME IS THERE A WAY TO MODEFY OR CHANGE MY DEFAULT THEME? I ALREADY TRIED ADVANCED LAUNCHER BUT I
-
HP Desktop: bootmgr is missing
BootMGR is missing, and since the PC win 7 of the factory, I don't have the same windows to recover, but there are files I have to recover before I can do the reinstall with an another win 7 CD, how can I go about this please?
-
Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas: You have problems with programs Error messages Recent changes to your computer What you have already tried to solve the problem
-
Is there a Microsoft Security Essentials (MSE) for Windows 8 or is it fair to Defender. My laptop came with Norton and it is about to expire and wanted to know if I could replace it with MSE?