Column with values separted by commas
I have a column which brings back a series of numbers (as text) separated by commas e.g.
20145, 58896, 52369, 88745
I want to search this column and identify when there is a certain combination of these 5 digit numbers e.g.
if columncontents equal any of (12345,23445,34567) AND columncontents equal any of (88965,63258,36894) then say hi (or whatever)
Envisioning a formula in a separate column which evaluates the contents of the column in question and then turns RED or I insert some text.
Thank you so much!
The suitable formula should be like this
=(Match([Column];"12345") or Match([Country];"23445") or Match([Country];"34567") )
the above formula returns a TRUE for a match found. and a false other wise. then use alerters on the column to make it red or what ever.
Thanks,
Karthik
Similar Messages
-
UPDATE value in column with value in SAME TABLE
Hi all,
Here's my issue...
I have a table which records all incidents for a person.
The table looks something like this:
tbl_connect(person_Id NUMBer,
OLD_ID VARCHAR2(24),
CASE_NUMBER VARCHAR2(10),
CASE_TYPE VARCHAR2(10),
PERSON_ROLE VARCHAR2(30),
INCIDENT_TYPE VARCHAR2(40));
The table is populated from a source table with all fields except person_id. Person_id is a sequence number that gets generated if the person comitting the incident is a NEW PERSON to our system. OLD_Id is the unique identifier between the source table and tbl_connect to identify a person.
The problem: If an existing person commits a new incident, a new record will be inserted into tbl_connect without PERSON_ID. Since the person already is in the database the person_id already exists in tbl_connect for that person. I now need to UPDATE person_id column with the person_id that already exists for this person. How can i achieve this.
Ive been trying all sorts of update queries but nothing seems to work. ANy help will be appreciated. Thanks in advance.Frank,
Thanks for the speedy reply. Here is a sample table.
I know it's a bit confusing. The data that is being dumped into this table is information from a old system. The OLD_ID is in here because it is the relationship between this table and the old table. PERSON_ID is new to this system to identify a person uniquely. That is why i need them both in this table for right now.
So say my tbl_connect got populated with new info from the old table. As you can see, old_id=567A has comitted another incident. Since he already exists in tbl_connect, now i need to update person_id with the value of 1. Does that make sense now????? If old_id did not exist, all i would do is insert a new row and set person_id to the next sequence number.
TBL_CONNECT
PERSON_ID OLD_ID CASE_NUMBER CASE_TYPE
1 567A 12345 IR
1 567A 15236 MV
567A 98547 IR<--newly inserted record of same person -
Filling a column with value from other columns
Hello all!
Suppose i have the following table:
TableA(col_one int, col_two int, result int);I want to insert value to col_one and col_two, and result will be filled with the multiplication product of col_one and col_two.
ok firstly i know this is very redundant way of storing data and generally should not be used, but one case when this might come in handy is when we want to store a total payment amount of product price and quantity. this can be useful since product price can change overtime and we need to record the data as the transaction happens to avoid change in total payment over time (as the price drops or rises).
now with the problem:
I tried this in mysql and it works:
INSERT INTO TableA (col_one, col_two, result) VALUES (30, 20, col_one * col_two);but not in oracle, which output the following error:
>
ora 00984 column not allowed here
any idea on how to do it in oracle?
thank you very much :)
ps, thank you for the fast replies on my previous topic.If the insert is done inside PL/SQL you can return the primary key for the row (assuming the table has a primary key?!?) and then update based on that key, but this still introduces two statements where a single statement can suffice.
Why are you thinking so complicated? ;-)
If it is done in PL/SQL the you can do this:
create procedure addRow(p_value1 number,p_value2 number) is
p_result number;
begin
p_result:=p_value1*p_value2;
insert into table1 (col_one,col_two,result) values(p_value1,p_value2,p_result);
commit;
end;If you want to do this automatically when someone inserts a row (without providing the result) you have to use an insert trigger.
Dim -
Finding Updated Columns with Values in Rows
Hello,
I have a one requierment as below.
if I have Table ITEM with Below records
ParcelID
ItemCode
CurrentLocation
Destination
UpdatingTime
1010
GLS
ABC
XYZ
01-12-14
1015
PHM
SSS
ZZZ
01-12-14
If any of the column value is updated it will replicate to ITEMUPDATE table with old row and new row as well.
Suppose for ParcelID 1010 CurrentLocation Changed from ABC to CDE it will store in ITEMUPDATE table with both records
old and new and if ParcelID 1015 CurrentLocation Changed from SSS to KKK it will also store as below.
Now ITEMUPDATE table will have all records old as well as new rows as below.
ParcelID
ItemCode
CurrentLocation
Destination
UpdatingTime
1010
GLS
ABC
XYZ
01-12-14
1010
GLS
CDE
XYZ
02-12-14
1015
PHM
SSS
ZZZ
01-12-14
1015
PHM
KKK
ZZZ
01-12-14
Like this any column can update not only CurrentLocation.
Now the requirement is I want to know which columns is updated and what is the new value.
Some what results need to look like below.
ParcelID
Old_CurrentLocation
New_CurrentLocation
1010
ABC
CDE
1015
SSS
KKK
Please Anyone Can help me on this .
Thank You,
AvisHello Avis,
You need to store date and time in 'UpdatingTime' column in both ITEM and ITEMUPDATE tables.
If you store only date, you will not get desired results as there may be multiple records for a 'ParcelID' in the same date in ITEMUPDATE table. It is difficult to get the latest record from multiple records with same dates for a 'ParcelID' from ITEMUPDATE.
Alternatively you can create a surrogate key , like 'ItemUpdateID', in ITEMUPDATE from which we can get the latest record for a 'ParcelID'. The surrogate key can be a integer identity column so that automatically incremented and updated for each insert
in ITEMUPDATE. Then it is easy to get latest UpdatingTime for a ParcelID from ITEMUPDATE table.
If the table design and data is something as below:
ITEM table
ParcelID ItemCode CurrentLocation Destination UpdatingTime
1010 GLS ABC XYZ
2014-01-12
1011 MMX ABD XVB
2014-01-12
1015 PHM SSS ZZZ
2014-01-12
ITEMUPDATE table
ItemUpdateID ParcelID ItemCode CurrentLocation Destination UpdatingTime
1 1010 GLS
ABC XYZ 2014-01-12
2 1015 PHM SSS
ZZZ 2014-01-12
3 1015 PHM
KKK ZZZ 2014-02-12
4 1010 GLS
CDE XYZ 2014-02-12
5 1011 MMX
ABD YYY 2014-01-12
Here 'ItemUpdateID' is identity column.
The SELECT query can be written as below:
SELECT A.ParcelID, A.ItemCode,
B.CurrentLocation 'New_Location',
ISNULL((SELECT CurrentLocation FROM ItemUpdate WHERE ItemUpdateID = (SELECT MAX(D.ItemUpdateID)
FROM ItemUpdate D WHERE D.ItemUpdateID < B.ItemUpdateID AND D.ParcelID = B.ParcelID)), A.CurrentLocation) 'Old_Location'
FROM Item A
LEFT JOIN ItemUpdate B On B.ParcelID = A.ParcelID
AND B.ItemUpdateID = (SELECT MAX(ItemUpdateID) FROM ItemUpdate C WHERE C.ParcelID = B.ParcelID)
The result will be as follows:
ParcelID ItemCode New_Location Old_Location
1010 GLS CDE ABC
1011 MMX ABD ABD
1015 PHM KKK SSS -
Dynamic update of column with values derived by formula on other table.
i have 3 tables; table A,B and C
table A has two columns (id and Quantity), based on the id value, the quantity value is computed using a formula on two rows (one from table B and the other from C).
the formula is different for each id value.
but after every month the quantity value has to be updated (because tables B & C get updated monthly).
example. given id=1, quantity= select round((sum(h.col1)/sum(p.col1), 2) from B p, C h
given id=2, quantity=select round((sum(col1)/sum(col3)), 2) from C
so for every id the quantity is derived by a different formula, but the quantity value has to be recomputed every month.
need help.1. update table a
quantity = decode (id,1, <formul1>, id,2 , formula 2...)
2. if you wanto schedule this as monthly task
use dbms_job.submit
send the above query to "What" parameter. -
BO: separate column for + - sign apart from column with value
Hello
In Business Objects Web Intelligence I would like to create a column that shows the sign '+' or '-' when a key figure KF1 is below 0 or above. How do I do this? It has to be a separate column. I already created a calculated key figure KF2 that has as formula ABS (KF1). KF1 itself must not be shown as contains amount and sign in one field. I need to separate these 2.
Regards
ArjanYou can create one more variable with the formula:
=If([Key FIG 1]<0) Then "-" Else "+"
Regards,
Rohit -
Update A Column with value of Column in the next Row
Hi All,
I have a table which is like this
ID NUMBER,
SUB_ID NUMBER,
STARTDATE DATE.
The Value is say for example like this:
ID SUB_ID StartDate
1 1 1-JAN-09
1 2 20-FEB-09
1 3 1-MAR-09
2 1 10-JAN-09
2 4 10-APR-09
2 3 1-MAR-09
2 2 2-FEB-09
I have to add a new column END DATE in the table and populate a value which is One Day less than the value of
start Date for next row. I have to order by ID and SubID and so that colum looks like this.
ID SUB_ID StartDate END DATE
1 1 1-JAN-09 19-FEB-09
1 2 20-FEB-09 28-FEB-09
1 3 1-MAR-09 DEFAULT-END DATE
2 1 10-JAN-09 1-FEB-09
2 2 2-FEB-09 8-Mar-09
2 3 9-MAR-09 9-APR-09
2 4 10-APR-09 DEFAULT END DATE
Can this be achieved using a single update query or I have ot write a Procedure ...any help will be appreicaitedor
merge into test
using (select rowid rid
, id
, sub_id
, startdate
, lead (startdate) over (order by id, sub_id) - 1 ed
from test) x
on (x.rid = test.rowid)
when matched then
update set end_date = x.ed
; -
Update a column with value of column of other table
Hi,
I am looking for an update statement for the following scenario
With following 2 tables
TABLE1 (Primary A, B)
TABLE2 (Secondary C , D).
C Column is not unique.
Please provide me an update statement to update TABLE1.B with TABLE2.D where TABLE1. A = TABLE2.C
Please note that TABLE2.C is not unique.
Please let me know whether this satement is correct.
UPDATE TABLE1
SET B = (SELECT DISTINCT D FROM TABLE 2 WHERE A=C )
Thanks
Alla KishoreUPDATE TABLE1 T1
SET T1.B = (SELECT DISTINCT D FROM TABLE2 T2 WHERE T2.C=T1.A ) -
Hi All.
I have a control file which i need to add a column with header data value.
example
data file:
123456;201303
santiago;producto1;100
santiago;producto2;200
valparais;producto1;400
valparais;producto3;900
The control file skip the first column and load the three columns on the table, but, now i need to add other column with 201303 value constant of the first record and load it on the table.
Then
select * from table:
santiago producto1 100 201303
santiago producto2 200 201303
valparais producto1 400 201303
valparais producto3 900 201303
How i do this in the control file?
Regards!SCOTT@orcl_11gR2> host type test.dat
123456;201303
santiago;producto1;100
santiago;producto2;200
valparais;producto1;400
valparais;producto3;900
SCOTT@orcl_11gR2> host type test1.ctl
options (load=1)
load data
infile test.dat
replace
into table onecol_onerow
fields terminated by ';'
trailing nullcols
(filler1 filler, newcol)
SCOTT@orcl_11gR2> host type test2.ctl
options (skip=1)
load data
infile test.dat
append
into table test_tab
fields terminated by ';'
trailing nullcols
(col1, col2, col3,
newcol expression "(select newcol from onecol_onerow)")
SCOTT@orcl_11gR2> create table onecol_onerow
2 (newcol number)
3 /
Table created.
SCOTT@orcl_11gR2> create table test_tab
2 (col1 varchar2(15),
3 col2 varchar2(15),
4 col3 number,
5 newcol number)
6 /
Table created.
SCOTT@orcl_11gR2> host sqlldr scott/tiger control=test1.ctl log=test1.log
SQL*Loader: Release 11.2.0.1.0 - Production on Mon May 6 10:46:44 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 1
SCOTT@orcl_11gR2> select * from onecol_onerow
2 /
NEWCOL
201303
1 row selected.
SCOTT@orcl_11gR2> host sqlldr scott/tiger control=test2.ctl log=test2.log
SQL*Loader: Release 11.2.0.1.0 - Production on Mon May 6 10:46:45 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 4
SCOTT@orcl_11gR2> select * from test_tab
2 /
COL1 COL2 COL3 NEWCOL
santiago producto1 100 201303
santiago producto2 200 201303
valparais producto1 400 201303
valparais producto3 900 201303
4 rows selected. -
ORA-01400 - not null column with default value and item with authorization
I've searched - I would think someone has run into this. APEX 3.0.0.00.20 - I've created a simple form on a table. One of the column is a not null column with a default value. I have a select list on that item, but it has security on it - authorization scheme. So, it checks the user and if that user isn't of the right role, it will not even display that item. However, APEX appears to still send in the column in its sql! So, the default value is useless, it sends in null each time. Even if I set the default at the Item level, I get null. Argg. That's got to be a bug...
In debug, I do not see the item listed at all. It's not used. That's fine - but why is it trying to insert the value? I would think it would leave it off??? I think because the item is associated with a database column. But, getting around this is ugly. Having to create a hidden item for each one, and then check to see if I need to take the list value... horrible. Any way to get around this???I should add - I guess I can always put my own custom process in to replace the DML. Just seems like a simple thing - if the value doesn't appear on the debug, isn't set with any default value... don't include it in the DML.
-
Sql query slowness due to rank and columns with null values:
Sql query slowness due to rank and columns with null values:
I have the following table in database with around 10 millions records:
Declaration:
create table PropertyOwners (
[Key] int not null primary key,
PropertyKey int not null,
BoughtDate DateTime,
OwnerKey int null,
GroupKey int null
go
[Key] is primary key and combination of PropertyKey, BoughtDate, OwnerKey and GroupKey is unique.
With the following index:
CREATE NONCLUSTERED INDEX [IX_PropertyOwners] ON [dbo].[PropertyOwners]
[PropertyKey] ASC,
[BoughtDate] DESC,
[OwnerKey] DESC,
[GroupKey] DESC
go
Description of the case:
For single BoughtDate one property can belong to multiple owners or single group, for single record there can either be OwnerKey or GroupKey but not both so one of them will be null for each record. I am trying to retrieve the data from the table using
following query for the OwnerKey. If there are same property rows for owners and group at the same time than the rows having OwnerKey with be preferred, that is why I am using "OwnerKey desc" in Rank function.
declare @ownerKey int = 40000
select PropertyKey, BoughtDate, OwnerKey, GroupKey
from (
select PropertyKey, BoughtDate, OwnerKey, GroupKey,
RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
from PropertyOwners
) as result
where result.[Rank]=1 and result.[OwnerKey]=@ownerKey
It is taking 2-3 seconds to get the records which is too slow, similar time it is taking as I try to get the records using the GroupKey. But when I tried to get the records for the PropertyKey with the same query, it is executing in 10 milliseconds.
May be the slowness is due to as OwnerKey/GroupKey in the table can be null and sql server in unable to index it. I have also tried to use the Indexed view to pre ranked them but I can't use it in my query as Rank function is not supported in indexed
view.
Please note this table is updated once a day and using Sql Server 2008 R2. Any help will be greatly appreciated.create table #result (PropertyKey int not null, BoughtDate datetime, OwnerKey int null, GroupKey int null, [Rank] int not null)Create index idx ON #result(OwnerKey ,rnk)
insert into #result(PropertyKey, BoughtDate, OwnerKey, GroupKey, [Rank])
select PropertyKey, BoughtDate, OwnerKey, GroupKey,
RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
from PropertyOwners
go
declare @ownerKey int = 1
select PropertyKey, BoughtDate, OwnerKey, GroupKey
from #result as result
where result.[Rank]=1
and result.[OwnerKey]=@ownerKey
go
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Report with long column cell value
Hi,
we have report with some number of columns and some columns cells have value with a lot of chars (more than 100). We would like to trim this column cell value to for example 20 chars and put all chars of column cell value to HTML TD title value as "hint". Something like this:
<code>
<td #ALIGNMENT# headers="#COLUMN_HEADER_NAME#" title="#FULL_COLUMN_VALUE#" class="data">#TRIMED_COLUMN_VALUE#</td>
</code>
It is possible do this by template? Do you have any idea?
I have one idea that use JavaScript and full column value in hidden column, but I thing that there could be some better way to do this:-)
With regards.
David
Edited by: user4893970 on Nov 23, 2010 4:11 PMWhile I don't think there's any way to do this with a normal reportIf it is a standard report and not an interactive report, then it can be done using the column HTML Expression:
<span title="#FULL_COLUMN_VALUE#">#TRIMMED_COLUMN_VALUE#</span> -
How to Add column with default value in compress table.
Hi ,
while trying to add column to compressed table with default value i am getting error.
Even i tried no compress command on table still its giivg error that add/drop not allowed on compressed table.
Can anyone help me in this .
Thanks.Aman wrote:
while trying to add column to compressed table with default value i am getting error.This is clearly explain in the Oracle doc :
"+You cannot add a column with a default value to a compressed table or to a partitioned table containing any compressed partition, unless you first disable compression for the table or partition+"
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_3001.htm#sthref5163
Nicolas. -
Update column with ROW_NUMBER() value
I have a column that I would like to update with a ROW_NUMBER() value partitioned by a specific column.
CREATE TABLE ##tmp (id INT NULL,
value1 VARCHAR(10),
value2 VARCHAR(10))
INSERT INTO ##tmp (value1,
value2)
VALUES ('A', 'asdfasdf'),
('A', 'asdf'),
('A', 'VC'),
('B', 'aasdf'),
('C', 'sdfgs'),
('C', 'xdfbhsdty'),
('C', '23sdgfg'),
('C', '234')
-- update the ID column with the values below
SELECT ROW_NUMBER() OVER (PARTITION BY Value1 ORDER BY Value2),
Value1,
Value2
FROM ##tmp
I have 14 million records. Can someone explain the best way to do this? Does the ORDER BY destroy performance for this many records?
Thanks!CREATE TABLE ##tmp (id INT NULL,
value1 VARCHAR(10),
value2 VARCHAR(10))
INSERT INTO ##tmp (value1,
value2)
VALUES ('A', 'asdfasdf'),
('A', 'asdf'),
('A', 'VC'),
('B', 'aasdf'),
('C', 'sdfgs'),
('C', 'xdfbhsdty'),
('C', '23sdgfg'),
('C', '234')
-- update the ID column with the values below
; with cte as (
SELECT ROW_NUMBER() OVER (PARTITION BY Value1 ORDER BY Value2) as RowNumber,
Value1,
Value2
FROM ##tmp
update cte
set Id = RowNumber;
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com -
When I quit itunes it restarts again with the dot under the itunes logo but the iTunes window doesn't open until I click the icon on the dock. Also in the middle of the size vale in the size column the value starts with a number then a ? then a number.
This forum is for questions from those managing sites on iTunes U, Apple's service for colleges and universities to post educational material in the iTunes Store. You'll be most likely to get help with this issue if you ask in the general iTunes for Mac forums.
Regards.
Maybe you are looking for
-
When I extracting data from DSO to Cube by using DTP.
When i am extracting data from DSO to Cube by using DTP. I am getting following erros. Data package processing terminated (Message no. RSBK229). Error in BW: error getting datapakid cob_pro (Message no. RS_EXCEPTION105). Error while extracting from s
-
I have Oracle 10g Express Edition 10.2.0.1.0 under Windows XP SP2 on my Personal Computer. There is installed the too , which is working fine. Also I have Oracle 10g Standard Edition 10.2.0.1.0 (after installing Oracle 10g BI SE One) under Windows 20
-
Failure of duplicate - ORA -06054
Hi, After a backup, we have a duplicate script running to copy it over to other server. Sometimes, when there is extra activity on the db and the backup takes longer, the duplicate fails with this: RMAN-03002: failure of Duplicate Db command at 04/08
-
Miix 3, Screen stays lit when with closed lid, how di o fix ?
I Have a miix 3 10" wint folio cover. I noticed the screen is stil lit up inside, whe the lid is closed. This off cpurdsedrains the battery for no reason at all. How do i make it turn off the screen enediately when its closed? I dont want it to go in
-
Authorization Object for Clear G/L account (trx F-03)
Hi, my client wants need to restrict some G/L accounts for certain company codes when clearing G/L accounts. In other words, I need to check that some users are cannot clear (trx F-03) some G/L accounts for some company codes. I have reviewed the aut