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


ADVERTISEMENT

ORA-01747 - Oracle Reserved Words - Query Table Matching Database With NUMBER Column?

Oct 1, 2012

I am having issue with Oracle reserved words, one of the application is using table which has NUMBER as column. I am not able to query that table matching database with NUMBER column.

HERE

select a.*
from DOC a , FOLDER B
where a.NUMBER= B.INCIDENT_ID
and b.open = 'Closed'; I tried double quotes (“”) and sigle quotes too, none of them worked.

View 12 Replies View Related

SQL & PL/SQL :: Count Of Repeated Words In A Column?

Mar 1, 2012

I have a table with the following column and data is like this.

SQL>CREATE TABLE test (
column1 varchar2(50));
SQL>INSERT INTO test VALUES('ABC XYZ');
SQL>INSERT INTO test VALUES('MNO PQR');
SQL>INSERT INTO test VALUES('ABCD ABC');
SQL>INSERT INTO test VALUES('PQR MNOP');

[code]....

View 13 Replies View Related

SQL & PL/SQL :: Find Top 20 Most Occurred Words In Particular Text Column

Mar 27, 2013

My requirment is to find the top 20 most occurred words in the perticular text column accross the full table. i WILL have desc column which is plain text where user wites the essay. i have below 2 data example where i have 2 find which word occur most of the time. i have more than 1 million data where i have to perfor this calculation

E.g
INCIDENT_NOINITIAL_SD_FAULT_DESC 70000030 late entering service on the outer rail causing a 4 minute delay. After speaking to the Hainault DDM and the Hainault DMT it has been established that 70000031E105 on entering into platform by one cars lenght applied emergency brakes to stop the train due to a person under his train. Train stopped with two cars still outside the platform. I received a call from Line Controllor at 0823 hrs that a person has jumped in front of train 105 at Greenford. I informed Ian Williamson Train Operations Manager. We traveled on a special taxi with a spare Train Operator at 0839hrs and reached Greenford Station at 0859hrs. Emergency Services ( Police, London Ambulance, London Fire Brigade and ERU)

CREATE TABLE tbl_incd(
INCIDENT_NO NUMBER ,
SD_DESC VARCHAR2(4000 BYTE)
)
data for the above table
Insert into tbl_incd ( INCIDENT_NO, SD_DESC)
Values
(70000031,

'E105 on entering into platform by one cars lenght applied emergency brakes to stop the train due to a person under his train. Train stopped with two cars still outside the platform. I received a call from Line Controllor at 0823 hrs that a person has jumped in front of train 105 at Greenford. I informed Ian Williamson Train Operations Manager. We traveled on a special taxi with a spare Train Operator at 0839hrs and reached Greenford Station at 0859hrs. Emergency Services ( Police, London Ambulance, London Fire Brigade and ERU) were already on site. When spoken to Line Controlllor stated he received a normal radio call from E105 to inform him that he has got a person under his train. At 0826 Line Controllor had traction current switched off between Northolt and Greenford. Train service was suspended from North Acton to West Ruislip in both directions (east and west).

I could not speak to the Train Operator as Police was in the process of interviewing him and he was too traumatised to speak. Trauma Support was arranged from Loughton as we had no one available at West Ruislip and White City. Trauma Support spoke to T/OP over the telephone and Train Operator decided to travel in a special taxi which was booked for him on his own, although a Station Staff was was arranged to travel with him. During the process a spare T/OP stayed with this T/OP. When spoken to Mr. Clack Operations Security Manager stated he was traveling on this train from West Ruislip and made a telephone call to Network Operations Centre at 0826hrs to inform them of the situation. Mr. Clack travelled to the leading cab and confirmed that although the T/OP was badly shaken but he carried out his duties in a professinal manner by placing Short Circuiting Devise in front of the train and second SCD was placed on the rear of the track by Station Supervisor after traction current was discharged. Passengers were detrained by operation butterfly cock. Les Blaxwall Operations Standards Manager was also travelling on this train and offered his to T/OP. Mr. Blaxwall assisted in the wrong direction move and stayed till the end of the operation to assist. Wrong Direction move was carried out by T/OP Martin to assist emergency services for the track search. The deceased was an elderly of Asian origin approximately of 65yrs of age wearing white shirt, beige trauser and white trainers. When CCTV was viewed he was seen pacing up and down on the east bound platform near the waiting room. On approach of T105 he jumped in front of the train at 0824hrs and train stopped with two cars outside the station. The body was removed from platform at 0940hrs by ERU and taken in a body bag to the secure room at Greenford Station. Track was accessed by BTP to carry out track search for any trace of identification at 0932hrs and gave all clear at 0942hrs.

TOM Williamson assisted in closing the train doors by operating the butterfly cock to close position. Traction Current was switched on at 0948hrs and T105 was worked empty to North Acton and reversed to Ruislip Depot. All clear was given at 0951hrs and after station search, Greenford Station was re opened at 0955hrs. E142 was the first train to run in service on the east bound. Body was removed at 1013hrs from Greenford Station and taken to Uxbridge by the police. Trauma Support was offered to Station supervisor by his DSM, but he declined the offer. Service Manager and Line Controllor were kept informed by myself.');
Insert into tbl_incd ( INCIDENT_NO,SD_DESC)
Values

( 70000032'PART OF TRAIN WITHDRAWAL Train 17 had a 6 min delayed departure from White City due to the train having a defective speedometer. Train was changed over and dud train was sent to Ruislip Depot for the attention of the DDMs staff. Ruislip DDM confirmed that the speedometer was defective. This was traced to a defective ATP controller.');
Insert into tbl_incd ( INCIDENT_NO, SD_DESC)
Values

( 70000033,' had a 1 min delayed arrival at Ealing Broadway due to the train having problems at signal EAB2058. The T/op stated that the train was in ATO and was stopped at the red signal (2058). The signal cleared and the train moved forward, the signal went straight back to red and the train stopped. This happened once again. The train did not pass the signal. T/op contacted the Line controller via radio and the signal was cleared, with the train proceeding into the platform at Ealing Broadway. The train was taken to Hainault for the attention of the DDM and a download. Train download and Tracker net confirm the T/op`s account of events. Due to the serious implications of events, an investigation is being undertaken by the Duty Engineer at Wood Lane. The T/op carried out his duties in a professional and correct manner and informed the passengers of the situation as and when required.');
COMMIT;

View 8 Replies View Related

SQL & PL/SQL :: Dynamic Column Creation / Create Column Based On Number Of Child In Hierarchy

Oct 15, 2013

I have one hirarchical query which return the parent to child hirarch level data. it has 11 level child data. i want to create column based on number of child in hirarchy. though i know it is 11 but it can change also.Is there any way i can create the column dynamically

ORG_UNITCOST_CENTERORG_UNIT_NAMEPARENT_ORG_UNITLLSYS_CONNECT_BY_PATH(ORG_UNIT,'/')

500171960000022000Managing Director - LUL500169965/00000001/50000001/50017588/50016996/50017196
500018370000021241FSO500171966/00000001/50000001/50017588/50016996/50017196/50001837
502894940000021241Knowledge Management500018377/00000001/50000001/50017588/50016996/50017196/50001837/50289494
508014980000021241Finance500018377/00000001/50000001/50017588/50016996/50017196/50001837/50801498

View 1 Replies View Related

Application Express :: Column Link Where Column Number Changes With Query

Feb 11, 2013

We are using Oracle 11g with Apex 3.2 on AIX. We are reporting data from customer satisfaction surveys. I'm using the following sql to create my report

<code>select * from(
select month,'Overall Satisfaction' as q_group, 1 as srt,Overall Satisfaction,site,
case when count(*) < 31 then '*' else
round((sum(ttos)/count(*))*100,0)||'/'|round((sum(bfos)/count(*))*100,0)||'/'||count(*) end ospct
from v_XXX_report a,(select distinct month_dt month from v_XXX_report) b
where Overall_Satisfaction is not null and year_dt = 2012

[Code]....

The problem is that site is not allways present and sometimes I have other variables in addition to site. This creates a situation where the month columns will not allways appear at the same column number. For example, When I run this query as is then the "JAN" column is Col3 (first column is a break, col2 is not shown). When I run this query without site then "JAN" is the second column. I would like to create column links for the "JAN" - "DEC" columns but not for any other columns.

Another issue - in the column link creation screen I can create up to 3 variables that I can pass to the next page. Since my query is a pivot I'm uncertain how to pass the column heading or the row value (for col2)

ie
Overall Satisfaction JAN FEB MAR APR MAY ...
Overall Satisfaction 12/12/200 12/12/210 12/12/220 12/12/230 12/12/240...
Recommend 12/12/200 12/12/210 12/12/220 12/12/230 12/12/240...
etc.

So if I clicked on the values at Recommend:FEB how can I get "Recommend" and "FEB" into variables that I can use on the next page? I've tried #column_name#, #month#, #q_name# and #APEX_APPLICATION.G_F10# but no luck.

View 0 Replies View Related

PL/SQL :: Bitmap Index On Number Column X Char Column?

Jul 23, 2013

is there some performance/access difference between a bitmap index on a number column and char(1) column? Both columns are not null with a default value.My application has a querie like this:  

select ass.column20,  ass.column30from table_a pucinner join table_b asson ass.column1 = puc.column1where pc.column_char = 'S'and ass.column_char02 = 'P'    

If I create a bitmap index on column "column_char", the access plan is not changed. But changing the column datatype to number(1) and obviously the values, the index is accessed and the cost decreases.This table has 4.000.000 rows. Oracle 11.2.0.2SO

View 7 Replies View Related

SQL & PL/SQL :: Converting Number Column To Date Column

Dec 25, 2012

I have a partitioned table with ~50 million rows that was setup with a number(10) instead of a date column. All the data in the table is ALWATS in this format YYYYMMDD

CREATE TABLE T1.monthly
(
SEQ_NUM NUMBER(10) NOT NULL,
DAY_DK NUMBER(10) NOT NULL
)
TABLESPACE USERS
PCTUSED 0
PCTFREE 10
[code]........

some sample data

SEQ_NUM DAY_DK
---------- ----------
990 20121225
991 20121225
992 20121225
993 20121225
994 20121225
995 20121225
996 20121225
997 20121225
998 20121225
999 20121225

When I use the exchange partition method the parition is able to move the data from "monthly" table to "mth" table.

desc t1.mth; ### my temorary table
Name Null? Type
----------------------------------------- -------- ----------------------------
SEQ_NUM NUMBER(10)
DAY_DK NUMBER(10)

Than when I try to alter my temp table "mth". I get an error table must be empty to change column types.

alter table n546830.mth modify (DAY_DK date);

Next I tried making my temporary table "mth" a date column. When I an the exchange partition command I get the following error:

alter table t1.monthly exchange partition DEC_2012
with table t1.mth without validation;
alter table n546830.monthly exchange partition DEC_2012 with table n546830.mth without validation
*
ERROR at line 1:
ORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITION

Method I can use to convert a number(10) to date column and keep the information in a table. Note, I don't care about HH:MM:SS as I never had that information to begin with and would be happy to set that part of the date column to all zeroes "00:00:00"

View 12 Replies View Related

Client Tools :: Number Data Type Column Does Not Display As Entered?

Jun 28, 2010

Now i have a problem which i am facing for the first time. The problem is:

I have created a table test1 with two column of number data type and the column witdth is 25. Then enter the data but when i select the recrod it does not display the column data as it was entered.
SQL> create table test1
2 (
3 startno number(25),
4 endno number(25)
5 );

Table created.

SQL> insert into test1

[code]...

View 5 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

PL/SQL :: Insert Number Into Column With Type  NUMBER(10,0)

Sep 28, 2012

my column type is NUMBER(10,0) ,it accept the input value from text field I using TO_NUMBER(?) to insert value into table, is the a way to handle if the input is 'aaaaaaaaaa' not digit?

View 6 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

SQL & PL/SQL :: Count Number Of Words In A String Separated By Comma

Aug 31, 2011

I need writing sql which can return the Count of Comma's in a string. Here is my table and data

CREATE TABLE TEST1(SNO NUMBER,STR1 VARCHAR2(30));

INSERT INTO TEST1 VALUES(1234,'ABCD,LL LT,MP');
INSERT INTO TEST1 VALUES(1456,'PP MR');
INSERT INTO TEST1 VALUES(1589,NULL);
INSERT INTO TEST1 VALUES(1897,'PP MR,FTR CLR ON');

Here is the output I am expecting

SNO STR1 STR1_COUNT
1234 ABCD,LL LT,MP 3
1456 PP MR 1
1589 0
1897 PP MR,FTR CLR ON 2

Basically I need to the count of Words separated by comma

View 9 Replies View Related

SQL & PL/SQL :: Why Doesn't Number Add Up When Do SUM On Column

Mar 21, 2011

I think I am having a rounding issue, but not sure. If I add all 4 rows below I get 1530.06. But when I use SUM, I get 1529.87

select PAY_EVENTS_AMOUNT
from PAYROLL_PAY_EVENTS_T1 PPET1
where ppet1.regnum = 130402134
and ppet1.pay_period = 2

PAY_EVENTS_AMOUNT
=================
-1499.19
2998.38
-30.68
61.36
=======
1530.06 TOTAL

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

select sum(PAY_EVENTS_AMOUNT ) PAY_EVENTS_AMOUNT
from PAYROLL_PAY_EVENTS_T1 PPET1
where ppet1.regnum = 130402134
and ppet1.pay_period = 2

PAY_EVENTS_AMOUNT
=================
1529.87 TOTAL

View 12 Replies View Related

SQL & PL/SQL :: Modifying NUMBER (38) Column

Dec 30, 2005

In chapter 17 of the 'Oracle Database 10g, The Complete Reference' it says "You can increase or decrease the number of decimal places in a NUMBER column at any time". When trying to modify a column from NUMBER(38) to NUMBER(38,3) I get the ORA-01440 error. Is there a way around this when you have the maximum number of digits (precision = 38).

View 2 Replies View Related

Range Partitioning With Number Column

Apr 21, 2011

i have a requirement To partition a Table byRange partition with a Number column. but the issue is the range Must be in a Date datatype ,
For example

partition by range (date_key)
( PARTITION DEF VALUES LESS THAN ('01-SEP-10'))

the date_key column has values of date in number format. like "20101014"

View 2 Replies View Related

SQL & PL/SQL :: Extract Only Number Part Of Column?

Mar 25, 2010

In a table, I have a column in a table with the following values:

targetcol

30 WD
180 WD
70%
0
80%
180 CD
70%
0
7 WD
2 WD
0

-
-
-
-
-
-
-
-
-

where WD is working days and CD Calendar days.

I just need to extract number from above.

View 11 Replies View Related

SQL & PL/SQL :: Date Check On A Number Column

May 16, 2011

I have a column defined as Number( 8 ) which is supposed to have date values. I would like to check if all the rows in that table have valid dates. We could use to_date(coulmn_name, 'YYYYMMDD') and catch the rownums for error conditions using pl/sql. I would like to know if we could just do it using sql only and return the row numbers for those that are invalid dates?

View 5 Replies View Related

SQL & PL/SQL :: Update Column To Consecutive Number?

Apr 14, 2011

create table test_table(
rn varchar2(10),
col1 varchar2(10),
col2 varchar2(10),

[code]...

I want update col1 whis is null to max(col1) ++ in a row, order by cr_date like
1,1,20110102
2,2,20110101
3,null,20110105 => 3,5,20110105 because this row is after 20110103
4,3,20110104
5,null,20110103 => 5,4,20110103 because this row is before 20110105

update test_table
set col1 = (select max(col1) from test_table) + rownum
where col1 is null;

this gives ora-00933

View 6 Replies View Related

PL/SQL :: Verify The Number And Char Column

Oct 12, 2012

From a list of values from a number column, I need to verify is there any values not satisfying number(3).

Ex- I have a column col1 where we have following values

'qwq'
'12.3'
'1'
'15'

Can I write a query to check the value not satisfying number(3) datatype.Eg the query should return

'qwq'
'12.3'

as the above two will not fit in to number(3) datatype columns

View 13 Replies View Related

Interval Partitioning On Number Column?

Sep 19, 2013

11gr2, We need to do partition a existing table of size 20g, But partition key column is NUMBER type and data stored in unix date format.I would like to create a monthly partition table as below. But not able to create.

create table student (  ENTRY_ID number(5,1),  NAME varchar2(30 BYTE) )  partition by range ( fun_unix_to_date (ENTRY_ID) ) --> fun_unix_to_date is a customized function to convert unix time stamp to date format.   

INTERVAL (100)   ( PARTITION CATCH_ALL values LESS THAN (to_date('01-MAR-12','DD-MON-YY'))); 

ERROR at line 5:ORA-00907: missing right parenthesis

View 5 Replies View Related

SQL & PL/SQL :: Setting Column Value Depending On Number Of Month

Aug 1, 2011

My need is to calculate rows and write result into column:

c1 if current month is 1st in quarter,
c2 if current month is 2nd in quarter,
c3 if current month is 3rd in quarter.

How do I perform it?

View 22 Replies View Related

SQL & PL/SQL :: How To Get Total Number Of Occurrences Based On Value Of Column

Apr 20, 2013

I have a query that should return count the number of rows depending on the value of SLOT. The expected result will be like this:

WIPDATAVALUE SLOT N M
1-2 TRALTEST43S1 1 3
1-2 TRALTEST43S1 2 3
3 TRALTEST43S1 3 3
4-6 TRALTEST43S2 1 4
4-6 TRALTEST43S2 2 4
4-6 TRALTEST43S2 3 4
7 TRALTEST43S2 4 4

The M column is used to count the total number of occurrences of a SLOT. Now, as for the N field, this is used to count the occurrence of the SLOT. In my example for the SLOT TRALTEST43S1, it has three occurrences so M will be 3. Why 3, is because of the WIPDATAVALUE. The WIPDATAVALUE of TRALTEST43S1 is 1-2 and 3. 1-2 WIPDATAVALUE signifies two occurrences (one to two) and 3 signifies only one occurrence. As for N, it should just count the number of occurrence. To further explain, see below:

WIPDATAVALUE SLOT N M
1-2 TRALTEST43S1 1 3 -> First occurrence in the total of 3
1-2 TRALTEST43S1 2 3 -> Second occurrence in the total of 3
3 TRALTEST43S1 3 3 -> Third occurrence in the total of 3
4-6 TRALTEST43S2 1 4 -> First occurrence in the total of 4
4-6 TRALTEST43S2 2 4 -> Second occurrence in the total of 4
4-6 TRALTEST43S2 3 4 -> Third occurrence in the total of 4
7 TRALTEST43S12 4 4 -> Fourth occurrence in the total of 4

This is the query that I have so far:

SELECT DISTINCT
WIPDATAVALUE, SLOT
, LEVEL AS n
, m
FROM
(
SELECT
WIPDATAVALUE
, SLOT
, (dulo - una) + 1 AS m
[code]....

I think that my current query is basing its M and N results on WIPDATAVALUE and not the SLOT that is why I get the wrong output. I have also tried to use the WITH Statement and it works well but unfortunately, our system cant accept subquery factoring.

View 2 Replies View Related

SQL & PL/SQL :: Decrease Size Of Number Datatype Column

May 24, 2012

I want to decrease the size of testid column of number datatype in my "test" named table from size 20 to 15 and the data of maximum size is of 10 digits. but oracle throws an error "ORA-01440: column to be modified must be empty to decrease precision or scale". i cant understand why it is happening?

what is the reason behind it even though new size is maximum than the maximum size of existing data. but when i decrease the size of "varchar2" then oracle does not through any error.

View 3 Replies View Related

SQL & PL/SQL :: Update Column With Total Number Of Records

Apr 3, 2012

Table : Customer

Cust_idNameid
227ABC1
227ABC2
227ABC3
228XYZ1
228XYZ2
228XYZ3
228XYZ4

In one oracle table (Customer) we have multiple cust_id based on that, we want to populate id column as cust_id record count.

I have id column right now null and want result same as above.

View 1 Replies View Related

PL/SQL :: Dynamically Get Maximum Value Permitted In A Number Column?

May 18, 2013

How can we dynamically get maximum value permitted in a number column? Is there any in-built function in oracle for this?

e.g. Accrued_Interest NUMBER(10,4)

In this case maximum value that can be inserted in this column is "999999.9999".

View 2 Replies View Related

PL/SQL :: How To Get Total Number Of Occurrences Based On Value Of Column

Apr 20, 2013

here on your forum but has been following several threads ever since.So anyway here is the thing, I have a query that should return count the number of rows depending on the value of SLOT. Something like this:

WIPDATAVALUE          SLOT             N            M
1-2                   TRALTEST43S1     1            3
1-2                   TRALTEST43S1     2            3
3                     TRALTEST43S1     3            3
4-6                   TRALTEST43S2     1            4
4-6                   TRALTEST43S2     2            4
4-6                   TRALTEST43S2     3            4
7                     TRALTEST43S2     4            4-----

As you can see above, on the SLOT TRALTEST43S1, there are three occurrences so M (Total number of occurrences) should be three and that column N should count it. Same goes with the SLOT TRALTEST43S2. This is the query that I have so far:

SELECT DISTINCT
WIPDATAVALUE, SLOT
, LEVEL AS n
, m
FROM
(
  [code]...

I think that my current query is basing its M and N results on WIPDATAVALUE and not the SLOT that is why I get the wrong output. I have also tried to use the WITH Statement and it works well but unfortunately, our system cant accept subquery factoring.

View 23 Replies View Related

SQL & PL/SQL :: Check Constraint To Disallow Number In Varchar2 Column

Apr 21, 2010

I have table customer which contains a column CUSTOMER_FIRST_NAME

CUSTOMER_FIRST_NAME VARCHAR2(50)

What will be sql statement to add a constraint on the CUSTOMER_FIRST_NAME column of the CUSTOMERS table so that the value inserted in the column does not have numbers ?

View 34 Replies View Related

SQL & PL/SQL :: Query To Retrieve Number Of Not Null Rows For Each Column?

Jul 7, 2011

I need a generic query to generate total # of records for each table in a schema, total # of records that are not null for each column in the table, and total # of records that are null for each of those columns in those tables.

ex:

the output should look like this.

owner schema table_name total# recs in the table, column_name,
------ ------ ---------- ------------------------- -----------

# of records not null # of records null
---------------------- --------------------

View 12 Replies View Related







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