How To Get Column Name From Data

Sep 26, 2011

how to get the column name for a particular column value.example:

create table test(id number,col2 varchar,col3 varchar);

insert into test values(1,'true','false');
insert into test values(2,'false','true');
commit;

i want to select column name for data 'true' having id=1;

i.e) the answer must be 'col2'.

View 2 Replies


ADVERTISEMENT

SQL & PL/SQL :: Row To Column / Column Data Can Be Varied From 1 To Any Number Of Words

Mar 21, 2013

I have a table where i have description column which free text column, the data in description column is seperated and i want to corvert 1 row data in multiple rows dependeing on the number of words.

eg

id description
78664 Pumps Alarm from CAMS RTU154

In the above example this column has 5 word so i want data in 5 rows like below

78664 Pumps
78664 Alarm
78664 from
78664 CAMS
78664 RTU154

This column data can be varied from 1 to any number of words.

View 11 Replies View Related

PL/SQL :: Derived Column Data As New Column In SELECT

Jul 31, 2013

I have a INSERT query which is happening with a SELECT query.

 ===================================================

INSERT INTO tbl_fact_effort_lvl_data (  ...............       )                       
SELECT ria.report_id,report_status:  :,
((SELECT lov_num_val                                   
FROM tbl_reference_data                                
WHERE lov_type = 'FREQUENCY'   ) * (SELECT SUM(pph_task)
FROM tbl_ri_process                                      
WHERE report_id = ria.report_id )) TOT_YEARLY_PROD_HOURS   ,TOT_YEARLY_PROD_HOURS * tf.fac_value TOT_FACT_DATA,location_id                                                                                                      
FROM tbl_fact tf  LEFT JOIN ......... ;

==================================================== 

So, here I want to use column alias TOT_YEARLY_PROD_HOURS as another column to derive another column value TOT_FACT_DATA.

View 8 Replies View Related

SQL & PL/SQL :: How To Update Data In A Column From Another Column

Dec 28, 2010

I was wondering how can I do below statement in oracle

update table1 t1 set t1.column1 = t2.column2
from table2 t2 inner join table3 t3 on t3.column3=t2.column4
where t3.column5 is null

I tried read up merge and update, but not really understand how the syntax works in oracle.

View 2 Replies View Related

SQL & PL/SQL :: Getting Column Data As Column Heading?

Apr 20, 2012

I would like to have column data as column headers.

Tables:

skill_table
SKILL_ID | NAME
3431060 | Stomach
3431064 | Hand
3437806 | Finger

localnode_table (which actually has the order/alignment (like what is next and what is previous) of the name from skill table.

NODE_ID | PREVIOUS_ID | NEXT_ID
3431060 | | 3431064
3431064 | 3431060 | 3437806
3437806 | 3431064

How to make it appear like:

Stomach | Hand | Finger
3431060 | 3431064 | 3437806

View 3 Replies View Related

Inserting Data In New Column Where Table Has Huge Data

May 26, 2013

I am trying to add a new column in a table and insert data from another column of same table.

alter table POSITION add INT_MK_DATA_ID number(10,0) null;
update POSITION set INT_MK_DATA_ID = INST_MARKET_DATA_ID;
commit

As there are huge number of records in the POSITION table ...its taking for ever to execute this query.

View 1 Replies View Related

SQL & PL/SQL :: Extracting Data From LONG RAW Data Type Column

Oct 7, 2011

I have come one requirement where i need to extract data from a LONG RAW data type column.

View 7 Replies View Related

How To Name A Column From Data Stored In Certain Row

Oct 28, 2012

I am trying to name a column from data stored in a row (Phone number) I want to name it from the first 3 digits (Area code) and I have no clue how to do it I have googled but I think the query is a little too complicated for me to explain it and get a result from google or find it in a section of a book.

My phone numbers are strings, so I initially look for the first 3 characters and then start separating and counting, I can do that, the only problem I have is naming the column WITH the the first three digits that I just separated.

View 4 Replies View Related

Using Column Data As Table Name?

Nov 5, 2012

I have some tables. TABLE1 contains columns called query_id and a column called List_name TABLE2 holds a list of data and the TABLE_NAME = value in TABLE1 held under LIST_NAME TABLE3 contains column with Query_ID and other info.

Is it possible to grab the entry in TABLE1 under LIST_NAME as a TABLE_NAME in a data source?

View 1 Replies View Related

How To Name Column From Data Stored In Certain Row

Oct 28, 2012

I am trying to name a column from data stored in a row (Phone number) I want to name it from the first 3 digits (Area code) and I have no clue how to do it I have Googled but I think the query is a little too complicated for me to explain it and get a result from Google or find it in a section of a book.

My phone numbers are strings, so I initially look for the first 3 characters and then start separating and counting, I can do that, the only problem I have is naming the column WITH the the first three digits that I just separated.

I am trying to learn by myself how to use databases and am using the HR database that comes in oracle since I read in a forum that it is a great way to learn how to use queries.

I read about using Pivot to do it, but in pivot I need to know how many area codes there are. I will post a screen shot of the table that I am working on the other post

[URL].....

I can group by phone number with this:

SELECT SUBSTR(PHONE_NUMBER, 1, 3) AREA, COUNT(SUBSTR(PHONE_NUMBER, 1, 3)) TOTAL_COUNT
FROM EMPLOYEES
GROUP BY SUBSTR(PHONE_NUMBER, 1, 3);

But what I am interested in doing is that instead of Area appearing as a column, that the actual first 3 digits would appear as the column name.

This is kind of what I am trying to do, but instead of AREA appearing as column name I would like for each one of the area codes to appear as column name, here is the

SELECT DE.DEPARTMENT_NAME, EM.SEX, SUBSTR(EM.PHONE_NUMBER, 1, 3) AREA, COUNT(SUBSTR(EM.PHONE_NUMBER, 1, 3)) TOTAL_COUNT FROM EMPLOYEES EM, DEPARTMENTS DE WHERE DE.DEPARTMENT_ID = EM.DEPARTMENT_ID GROUP BY DEPARTMENT_NAME, EM.SEX, SUBSTR(PHONE_NUMBER, 1, 3) ORDER BY DEPARTMENT_NAME;

View 5 Replies View Related

SQL & PL/SQL :: Convert Row To Column In Data?

Aug 21, 2010

I have a Table as below

Attribute_namePrimary Seconday
DNS 204.109.167.1204.109.167.2
DNS 204.109.167.2204.109.167.3
NAT 138.20.37.136138.20.37.137
NAT 138.20.20.116138.20.20.117

For a Specific requirement

I need the select data output like below

[b]DNS NAT Type[/b]
204.109.167.1138.20.37.136Primary
204.109.167.2138.20.20.116Primary
204.109.167.2138.20.37.137Secondary
204.109.167.3138.20.20.117Secondary

View 2 Replies View Related

SQL & PL/SQL :: Trim Column Data

Mar 11, 2010

Need to do this

Column1
--------
5648_6844_20020201
6878_6845_20051201
9845_6548_20080307

Need to change it to this

Column1
--------
20020201
20051201
20080307

So I basically need to remove the leading part of the string using the "_" underscore as the delimiter.

So I thought this would work, but no luck.

SELECT LTRIM('_', Column1) "NewCOL" From table;

View 9 Replies View Related

SQL & PL/SQL :: Column Data Reference To Another?

Jan 20, 2011

how I can write a query that get a column data point to another column data in a csv file? For example:

Column A Column B
First Name Mike
Last Name Smith

View 6 Replies View Related

SQL & PL/SQL :: Data In Column-wise?

Jul 22, 2013

For one of our requirement, we are asked to provided data in below manner.

Deptno Deptname emp_name_1 hire_date_1 emp_name_2 hire_date_2
10 Sales Raghu 25-Jan-2007 Abbhilash 29-Mar-2009

If a particular department has 10 employees it should have data upto emp_name_10,if department has only 5 employess it should data upto emp_name_5 and so on.I came up with below approach, in this approach I need to create new table to store the data in row wise.

In my actual requirement 4 tables needs to be joined and 2 of the tables are very large.Is there any other approach without creating a new table, something within pl/sql.

drop table emp_dept;
create table emp_dept(deptno number,dept_name varchar2(100),emp_name varchar2(100),hire_date date,seq_cnt number,total_cnt number);
insert into emp_dept

[code]...

View 21 Replies View Related

SQL & PL/SQL :: How To Modify Column Data

Jun 8, 2012

i have one table emp in this table already data exist now i have to modity this existing column data so how can i do this

example:existing emp table

emp_no ename
1 dk patel
2 sk patel
3 jk patel

now i want to change this ename column data i want output like this below table

emp_no ename

1 dk
2 sk
3 jk

how can i do this.

View 4 Replies View Related

SQL & PL/SQL :: Clear Data On Column?

Jun 20, 2011

I have one table employer. It has column loginid, password, address, regdate, fullname, identno.

So i want to clear all data before 1 June 2011 in regdate. What command i need to use? I quite new with command prompt.

View 10 Replies View Related

SQL & PL/SQL :: What Should Be The Data Type For The Column

May 9, 2012

I have to create a table which should store data at Week level. The table have the following columns

Product id, Loc id, Business group id, FISCAL WEEK , Revenue,

Fiscal week column will have data as '2011-W01', '2011-W47' etc.

What should be the data type for fiscal week column. Based on this table i have to create a calculated column which should fetch trailing 12 weeks average for each row.

View 5 Replies View Related

SQL & PL/SQL :: Column Data In Rows

Aug 14, 2013

Currently I have a requirement where I need return data of different columns in rows.

For example: I have a table that contains monthly data for voice calls, sms count and mms count for each mobile. I will need to get the output as summary of voice calls, sms and mms counts in different rows. For this I am using an approach which I am not totally satisfied even though I am getting the required results (majorly because i am querying the table thrice for getting this data).

I would want to know about any alternate ways of implementation.

--Create table
Create table
UsageData
(Mobile varchar2(20),
CAL_MONTH Varchar2(20),
VOICE_CALL number(9),
SMS number(9),
MMS number(9)
);

--Data

insert into UsageData values ('9999','JAN',1,2,3);
insert into UsageData values ('9888','JAN',5,20,1);
insert into UsageData values ('9777','JAN',4,5,9);
insert into UsageData values ('9666','JAN',200,111,8);
insert into UsageData values ('9555','JAN',154,1534,3);
insert into UsageData values ('9444','JAN',0,2,212);

--Query

select 'VOICE_CALL' AS EVENT,sum(VOICE_CALL) AS UNITS from UsageData where cal_month ='JAN'
union all
select 'SMS',sum(SMS) from UsageData where cal_month ='JAN'
union all
select 'MMS',sum(MMS) from UsageData where cal_month ='JAN';

View 8 Replies View Related

PL/SQL :: Convert Row Data Into Column

Sep 25, 2013

I want to convert row data into column and I mentioned here,  

This is my table format, A       B        C------------------col1   1       101col2   2       102col3   3       103 

The above query need to like this, COL1      COL2      COL3----------------------------------1               2                3101           102            103  

View 5 Replies View Related

Hiding Column Data

Oct 30, 2012

I want to hide column data how to do and also clarify me how datamasking will work for hiding

View 9 Replies View Related

How To Get Binary Data From Geometry Column

Mar 21, 2011

How to get binary data from Geometry column?

I want to read GEOMETRY COLUMN data as binary, using GET_WKB() method. I'm able to read character data by using GET_WKT().
But our requirement is to read data in binary format and display it.

View 1 Replies View Related

How To Get The Column Data Consist Of % Symbol

Mar 15, 2009

I want a query to get the column data , which consists of % symbol ,using like .

Sample :

The varchar data type column consit of columns 100%,100 ,90% ,77% with the Query i have to get the rows as 100%,90% ,77%. (i can get the data using in operator but i want to know how to get that using like).

View 1 Replies View Related

SQL & PL/SQL :: How To Convert Rows Data Into Column

Nov 20, 2011

how to convert rows data into column...

View 7 Replies View Related

SQL & PL/SQL :: How To Change Column Data In Row Format

Jun 1, 2012

I want to get the following format of data in row format using PLSQL. I want to do that in using a shell script also.

Suppose I have the data like this

123
45
2
789

how to write it in PLSQL as follows:
1427
25 8
3 9

View 3 Replies View Related

SQL & PL/SQL :: Selecting Data Greater Than Some Value Into One Column

Jul 15, 2013

I have table TEST_REP with below data

DA SUMA
---------------------- ----------------------
2011 2
2011 3
2011 5
2012 2
2012 7
2014 2
2014 10
2015 2
2016 33
2015 26
2017 21
2017 2
2018 23

13 rows selected

I have used following query to get the below output:

select
br_mat MAT_YEAR,
sum(br_par) TOTAL
from (
(select to_char(da) br_mat,suma br_par from test_rep)
UNION ALL
[code].......

Output :

MAT_YEAR TOTAL
---------------------------------------- ----------------------
2011 10
2012 9
2013 0
2014 12
2015 28
2016 33
2017 23
2018 23
2019 0
2020 0

10 rows selected

Expected Output :

MAT_YEAR TOTAL
---------------------------------------- ----------------------
2011 10
2012 9
2013 0
2014 12
2015 28
2016 33
2017 and Greater 46

View 6 Replies View Related

SQL & PL/SQL :: Compare Values In A Column Data

Aug 29, 2012

I have an requirement like below and would like to have SQL for that.

Source Table:

EMP_NO EMP_CODE
1 'A'
1 'D'
1 'E'
1 'F'

2 'S'
2 'A'
2 'W'
2 'Q'

3 'A'
3 'T'
3 'D'
3 'E'

4 'D'
4 'A'

I want to load only data which has EMP_CODE as A and doesn't have subsequent 'E' or 'F' in it. In the above source you can see EMP_NO 2 and 4 satisfy the condition and rest wont. So i want the output data like below.

Desired output:

EMP_NO EMP_CODE
2 'A'
4 'A'

View 4 Replies View Related

SQL & PL/SQL :: Tricky Concatenation Of Data In One Column

Nov 26, 2010

Every prospect person in the prospect table are approached with a proposal. This proposal record is stored in the proposal table. Proposal is managed by many primary and proposal managers over the period of proposal. They are assigned the proposal in the assignment table. Primary managers have an assignment type 'PM' and proposal manager have a assignment type of 'PS'

i Need to make below1 and 2 changes to the script.

1-when proposal is current (proposal.active_ind = 'Y' ) then extract only currently assigned primary and proposal managers (assignment active_ind = 'Y') and these managers should be assigned after the proposal has started (assignment.start_date >= proposal.start_date )

2-when proposal is not current (proposal.active_ind = 'N' ) then extract even not curRent assigned primary and proposal managers (not use this in criteria assignment active_ind = 'Y') and these managers should be assigned only after the proposal has started (assignment.start_date >= proposal.start_date )

Primary/Proposal Manager column : Format to print as below:

All Primary managers seperated with space "/" between and all proposal managers after that and "*" at the end

For Example : Mary Steve Roger / Chris Danny Veronica * also, current script only extracts 5 primary managers and 4 proposal managers but thats ok. i can put 10 max(decode statements in the output cause i think they cannot have more than 10 managers.

/*script*/
SELECT DISTINCT p.prospect_id "PROSPECT ID"
,p.prospect_name "Prospect Name"
,pro.proposal_id
,pro.proposal_title "Proposal Title/Purpose"
, MAX(decode(pm_seq
,1
,primary_manager_name
,NULL)) || ' ' ||
[code]...

View 4 Replies View Related

SQL & PL/SQL :: Retrieve Data From Blob Column?

Sep 30, 2011

example for retrieve data from blob column using pl sql procedure in oracle?

View 2 Replies View Related

SQL & PL/SQL :: Insert Data In Clob Column?

Jun 13, 2012

i have a problem when i try to insert a large character string of nearly 1 lac characters (code of html) in a clob column of my test table, then i get an error "ORA-01704: string literal too long" , i didnot understand that why clob column is not storing this data.

View 1 Replies View Related

SQL & PL/SQL :: How To Print Rows Into Column Data

Sep 24, 2010

I have a table emp having data as

empno ename sal deptno
1001 manoj 1000 10
1001 sachin 2000 20
1003 manoj 30000 30

Now I wanted to write a query which will display the results like below. Row data need to be display in the columns

empno ename sal deptno 1001 manoj 10 20 1003 30
1001 manoj 1000 10 1001 manoj 10
1001 sachin 2000 20 1001 sachin 20
1003 manoj 30000 30 1003 manoj 1003 30

How to print the rows into column data?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved