SQL Help: Derive from 'News' columns based on condition
Hi allCan someone help me with this please? I am trying to achieve in a SQL (no), if this can be done in two different stages, even that is fine too...
Thanks in advance,
Chavigny
SELECT * FROM
(
SELECT 2765 BTCH_ID,'payroll' BTCH_NM,'payroll~EUR~EUR~DE'NEW_BTCH_NM,'1234'TMPLT_ID FROM DUAL
UNION
SELECT 2765,'payroll','payroll~USD~USD~US','1235' FROM DUAL
UNION
SELECT 2765,'payroll','payroll~USD~USD~US','1236' FROM DUAL
UNION
SELECT 2765,'payroll','payroll~GBP~GBP~GB','1237' FROM DUAL
UNION
SELECT 2766,'SALARY','SALARY~USD~USD~US','1238' FROM DUAL
UNION
SELECT 2766,'SALARY','SALARY~USD~USD~US','1239' FROM DUAL
) T_BATCH;
For a "batch - id", there are several Transactions that are denoted by (cr_crncy_cd, dr_crncy_cd, recvr_cntry_cd), and the "NEW_BTCH_NM" column is basically a concatenation of 'BTCH_NM' + above 3 columns (with a ~)I'm trying to derive two new columns "SEQ" & "Output_Batch_name".
The SEQ column:
For every batch_id, the first row will be assigned by sequence.nextval.
For all transactions within BTCH_ID,
all the rows with same NEW_BTCH_NM, share the same sequence number
if different, then SEQ.nextval for all distinct rows
Output_BTCH_NM: for a given batch_id,
if the NEW_BTCH_NM is the same for all transactions ( batch_id 2766 in the below example) ,
then Output_BTCH_NM = BTCH_NM should be marked for All transactions which belong to this Batch_id,
Else
Output_BTCH_NM = New_BTCH_NM
END if
EXPECTED RESULTS*BTCH_ID BTCH_NM NEW_BTCH_NM TMPLT_ID SEQ Output_BTCH_NM*
2765 payroll payroll~EUR~EUR~DE 1234 1 payroll~EUR~EUR~DE
2765 payroll payroll~GBP~GBP~GB 1237 2 payroll~GBP~GBP~GB
2765 payroll payroll~USD~USD~US 1235 3 payroll~USD~USD~US
2765 payroll payroll~USD~USD~US 1236 3 payroll~USD~USD~US
2766 SALARY SALARY~USD~USD~US 1238 4 SALARY
2766 SALARY SALARY~USD~USD~US 1239 4 SALARY
Published by: user10711957 on 25 Sep, 2010 16:37
An extension of the solution of the (slightly modified) jiq
function my_sequence(whichval in varchar2) return number is
begin
if whichval = 'currval' then
return your_sequence.currval;
else
return your_sequence.nextval;
end if;
end my_sequence;
WITH t AS
(
SELECT 2765 BTCH_ID,'payroll' BTCH_NM,'payroll~EUR~EUR~DE'NEW_BTCH_NM,'1234'TMPLT_ID FROM DUAL
UNION
SELECT 2765,'payroll','payroll~USD~USD~US','1235' FROM DUAL
UNION
SELECT 2765,'payroll','payroll~USD~USD~US','1236' FROM DUAL
UNION
SELECT 2765,'payroll','payroll~GBP~GBP~GB','1237' FROM DUAL
UNION
SELECT 2766,'SALARY','SALARY~USD~USD~US','1238' FROM DUAL
UNION
SELECT 2766,'SALARY','SALARY~USD~USD~US','1239' FROM DUAL
)
select btch_id,btch_nm,new_btch_nm,tmplt_id,
case when lag(seq,1) over (order by tmplt_id) = seq
then my_sequence('currval')
else my_sequence('nextval')
end seq,
out_btch_nm
select btch_id,btch_nm,new_btch_nm,tmplt_id,
dense_rank() over(partition by btch_id order by new_btch_nm) seq
case when count(distinct new_btch_nm) over (partition by btch_id) = 1
then btch_nm
else new_btch_nm
end out_btch_nm
from t
Concerning
Etbin
Posted before you see the following
the sequence # must be continuous, must avoid any shortfall or gaps with the numbering.
the foregoing must be the only user of its own sequence somehow and maybe...
Search for "sequence free gap"... http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:4343369880986
Edited by: Etbin on 26.9.2010 08:21
Tags: Database
Similar Questions
-
Display a column based on another column
Hello
I work in the Apex 4.2.
I have a tabular presentation based on a query.
In this form, I have a column of link change with an icon. When I click it, I open a new page with the details of my record.
I want that this column appears only when the user is entitled.
So, I got in my request a new column based on a Pl/sql function that returns 1 when the logged-on user has the privilege package update the record.
I call this new column "can_update."
After that, I changed the "conditional display" property of my edit_link column.
In type of condition, I put: "value for the element / the expression 1 column = Expression 2.
I put in the expression 1: can_update
I put in the expression 2: 1
But it does not work as I want. colonm "edit_link" never appears.
and the can_update column return the good value 1 or 0 on depend on the recording.
Anyone has an idea on what I didi wrong?
Thank you.
Laurent.
I found a solution to my problem.
I have a column in my query that return 'none' or 'inline' when I have the privilege to update my file and thus, the column "edit_link."
Thos query column name is link_disp
And in the "link attribute" property, the "link in the column" Section of my edit_link, I add: "style =" display: #LINK_DISP #»»
and it works well
Laurent.
-
Add the new column to Admin tool, including the SQL Code
Hi all
I am new to OBIEE and I already searched here in the forum but have not found an exact answer which could help me.
I have a table in the warehouse where to get information on employees. It's employe_id, manager_id and name.
Example:
Employe_id Manager_ID name
1 Mueller
2 1 Meier
Now, I would like to create a new column in the Mapping BI Admin tool business layer and add a SQL where to select the name of the Manager.
Is this possible? And how can we do it? It will work with a new logical column? Where we add the SQL Code?
I hope someone can answer my question!
Thank you very much!
Kind regards
DavidOK, I think I got it - the name of Manager is on a separate table (or a search to return to the current table) and your thinking that you want to label your SQL in the report to find the name of Manager based on Director ID, you have?
If so, import the table with the names of Manager in the physical layer. If this is the same table that you already have (but want to search him in the current table) then you need to create an alias for the current table.
For each new table in the Phy layer, or an alias - define the join (current_table.manager_id = manager_table_or_aliased_current_table.employee_id)
Once completed, we will on the source of the logic table in the MDB for this dimension, edit, on the general tab, "Add" and select the table / alias that you created in the phy layer. Click OK - it combines now two tables attached as a source - you can then map the name of the Manager search in your column 'name '.
Kind regards
Alastair -
I have problems with the CBC links when I create a new page from a template DWT. I hope someone can help me. Here's what I did.
- I copied an HTML page to a new site that I have created (1 Site) to an existing (Site 2) as well as all the images needed site and the CSS files.
- I edited the CBC code so that page copied to Site 2 (New Page) referenced the correct local CSS and image files
- I created a template the Page new DWT file in Site 2 but noted that the CBC links were still referencing image and CSS of the Site 1 files, so I edited this new as shown above.
- I created a new page, based on the model of TPL, but strangely, the CBC links are again referencing Site 1.
I don't understand what is happening. DW is clearly still remember the original links and ignores changes.
Thank you very much in advance for your help.
Gary
When I need to come a file from another site, here's what I do.
Go to Site 1. Open the file in Design view or Code view. Turn off Live View.
Go to Site 2. File > save as new_filename.html in the root directory of the Site 2.
DW should invite you to update the links. Press YES.
Close the Site 1 file.
Check the file links 2 Site to ensure that they document.
Validate code & solve the errors reported.
When you are completely satisfied with your document, click file > save as template.
DW will ask you to insert editable regions for content that changes from one page to another. To do this and save your template.
Close the model.
File > new > Site Template Page.
Press the button create.
SaveAs index.html (your home page).
Repeat for other pages of the site.
Nancy O.
-
How to fill the new column with values based on the subquery
How can I fill a new column (teamid) with the following query below, at my table dept? I'm empty/null entries in teamid collar when I run the code ff:
ALTER table dept add (teamid varchar2 (15));
Update dept
define the teamid = select upper (substr (deptname, 1, 3)) | Upper (substr (Color, 1, 2)) | rownum
of the Department;
Want to output:
DEPTNAME COLOR TEAMID SALES ORANGE SALOR1 ACCOUNTING BLUE ACCBL2 BILLING YELLOW BILL3 SQL> create table dept as 2 select 'SALES' deptname, 'ORANGE' color from dual union all 3 select 'ACCOUNTING' deptname, 'BLUE' color from dual union all 4 select 'BILLING' deptname, 'YELLOW' color from dual 5 / Table created SQL> SQL> select * from dept; DEPTNAME COLOR ---------- ------ SALES ORANGE ACCOUNTING BLUE BILLING YELLOW SQL> SQL> alter table dept add(teamid varchar2(15)); Table altered SQL> update dept set teamid = upper(substr(deptname,1,3)) || upper(substr(color,1,2)) || rownum; 3 rows updated SQL> select * from dept; DEPTNAME COLOR TEAMID ---------- ------ --------------- SALES ORANGE SALOR1 ACCOUNTING BLUE ACCBL2 BILLING YELLOW BILYE3 SQL> rollback; Rollback complete SQL> drop table dept purge; Table dropped SQL>
----
Ramin Hashimzade
-
Adding a virtual column derived from sdo_geometry?
Hi guys - maybe just a quick: do I do specifically to add a virtual as column the based on a geometry object?
SQL> select * 2 from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Linux: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production 5 rows selected. SQL> create table foo (id number 2 ,locn mdsys.sdo_geometry); Table created. SQL> SQL> alter table foo add (x number as (locn.sdo_point.x)); alter table foo add (x number as (locn.sdo_point.x)) * ERROR at line 1: ORA-54016: Invalid column expression was specified
I know that in a query, the table must be qualified with an alias as below:
don't know how to apply this to a virtual column.
SQL> insert into foo values (1,MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(151.213376,-33.865623,NULL),NULL,NULL)); 1 row created. SQL> select * 2 from 3 SQL> SQL> SQL> select f.locn.sdo_point.x 2 from foo f; LOCN.SDO_POINT.X ---------------- 151.213376 1 row selected. SQL>
Edit: what should we do to make the display in a fixed rate code in shape with a police?
For me it works with a user defined function:
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production PL/SQL Release 11.2.0.2.0 - Production CORE 11.2.0.2.0 Production TNS for 32-bit Windows: Version 11.2.0.2.0 - Production NLSRTL Version 11.2.0.2.0 - Production SQL> create table foo (id number 2 ,locn mdsys.sdo_geometry); Table created. SQL> insert into foo (id, locn) values (1,MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(151.213376,-33.865623,NULL),NULL,NULL)); 1 row created. SQL> create or replace function get_geometry_x (g mdsys.sdo_geometry) return number deterministic as 2 begin 3 return g.sdo_point.x; 4 end; 5 / Function created. SQL> alter table foo add (x number as (get_geometry_x(locn))); Table altered. SQL> select x from foo; X ---------- 151,213376
Message geändert durch hm
-
Derived from the existing columns
Hello
How to create a new column that has derive data from another table on this logic:
Table A
Name identity
1 dsf
2 homeless
3 SDS
Table B
ID name tableA_ID
1 dd 1
2 of 2
I added another column in table A in desperation to denormalize our data and didn't need to make a join to table B
ID name tableB_name
1 SD dsf
2 sdf of
3 SDS
basically just try to merge 2 tables with a 1-1 relationship. I tried to fill in the data of table B in A, but by making an inner join and when I query the data, does not return a row ID 3 in table a.In model MDB make outer join. Make sure that you select next outdoor table.
Score pls correct/good
-
I need help to the new photo of my photos from iphoto on El Capitan. Any help would be appreciated.
To migrate your iPhoto library to Photos for Mac, drag it in the Photos icon in the Dock. Photos will read the iPhoto library and create a new library of pictures of him.
Is your photo library in iPhoto on an external drive? The migration will work that if the external hard drive Mac OS extended (journaled) file system. If the library is on a disk with a different file system, Ministry of the environment of the library of a correctly formatted disk.
-
Hello
I have an emp_job_det with a, b, c columns table. Note that this TABLE ALREADY has DATA OF THESE COLUMNS
IAM now add a new column "D" with forced not null
Fistly I alter the table by adding the single column "D", if I do, the entire column would be created with alll of nulls for the column DEFAULT D
ALTER table emp_job_det Add number D; -do note not null CONSTRAINT is not added
Second... If I try to add the constraint not null, get an eoor as already conatained null values...
(GOLD)
In other words, if I put the query
ALTER table emp_job_det Add number D NOT NULL; -THROWS ERROR AS TABLE ALREADY CONTAINS DATA
So my question is how how can I add a new column with a constraint not null, table already has the data, without falling off the table
Please help me on this issue...
Add the column without constraint, then fill the column. Once all the rows in the table are given in the new column, and then add the constraint not null.
-
SQL help (line column... a little)
I'm a little weird to write query. I want to turn rows into columns, but they must be grouped by line # as well. They will have to be group by tracking #...
The other issue is, the system can have 5 minimum options and a maximum of 7. Here are the options...
So, in reality, he will be taking a set of lines (misc 5-7) and returning to the side to make the columns. But, the new column headers are always defined like this max 7 and 2 can be cancelled on if not available...
Confusing even explain... insert statement for example 2 below... we have 6, 7 criteria we met...
----------------------------------------------------------
Sector of activity
Type
Did you review the user guide?
Application
Enter your Message
Have you reviewed the FAQs?
Tracking number of EIS
-----------------------------------------------------------
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323646, 'application', "DRI INT");
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323646, 'Enter your Message', 'test');
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323646, 'have you seen the FAQ document?', 'No');
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323646, 'have you reviewed the user's guide?', 'No');
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323646, "line of Business", "AUTO");
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323646, 'Type', 'Suggestion');
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323647, 'application', 'BEST');
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323647, 'Enter your Message', 'test');
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323647, 'have you seen the FAQ document?', 'No');
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323647, 'have you reviewed the user's guide?', 'Yes');
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323647, 'Number of EIS path', 'none');
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323647, "line of Business", "MAPS");
Insert into the TABLE
(FIELDVALUES CAN ONLY BE TRACKINGNUMBER, NM_PARM)
Values
(323647, 'Type', 'Question');
COMMIT;with "TABLE" as ( (select 323646 TRACKINGNUMBER, 'Application' NM_PARM, 'DRI INT' FIELDVALUES from dual) union all (select 323646 , 'Enter Your Message', 'test' from dual) union all (select 323646 , 'Have you reviewed the FAQ document ?', 'No' from dual) union all (select 323646 , 'Have you reviewed the User guide ?', 'No' from dual) union all (select 323646 , 'Line Of Business', 'AUTO' from dual) union all (select 323646 , 'Type', 'Suggestion' from dual) union all (select 323647 , 'Application', 'BEST' from dual) union all (select 323647 , 'Enter Your Message', 'test' from dual) union all (select 323647 , 'Have you reviewed the FAQ document ?', 'No' from dual) union all (select 323647 , 'Have you reviewed the User guide ?', 'Yes' from dual) union all (select 323647 , 'ISW Tracking Number', 'none' from dual) union all (select 323647 , 'Line Of Business', 'CARDS' from dual) union all (select 323647 , 'Type', 'Question' from dual) ) , t as ( select distinct TRACKINGNUMBER tn from "TABLE" ) select (select FIELDVALUES from "TABLE" where NM_PARM = 'Application' and TRACKINGNUMBER = t.tn) "Application" ,(select FIELDVALUES from "TABLE" where NM_PARM = 'Enter Your Message' and TRACKINGNUMBER = t.tn) "Enter Your Message" ,(select FIELDVALUES from "TABLE" where NM_PARM = 'Have you reviewed the FAQ document ?' and TRACKINGNUMBER = t.tn) "Have you reviewed FAQ?" ,(select FIELDVALUES from "TABLE" where NM_PARM = 'Have you reviewed the User guide ?' and TRACKINGNUMBER = t.tn) "Have you reviewed User gui?" ,(select FIELDVALUES from "TABLE" where NM_PARM = 'ISW Tracking Number' and TRACKINGNUMBER = t.tn) "ISW Tracking Number" ,(select FIELDVALUES from "TABLE" where NM_PARM = 'Line Of Business' and TRACKINGNUMBER = t.tn) "Line Of Business" ,(select FIELDVALUES from "TABLE" where NM_PARM = 'Type' and TRACKINGNUMBER = t.tn) "Type" from t
Application Enter Your Message Have you reviewed FAQ? Have you reviewed User gui? ISW Tracking Number Line Of Business Type ----------- ------------------ ---------------------- --------------------------- ------------------- ---------------- ---------- DRI INT test No No AUTO Suggestion BEST test No Yes none CARDS Question
-
SQL query on how to add a new column to display the result
Select emp_code, < new column = 0 >
from employee_table where < < condition > >
syntax to add the new column?
Published by: user9027633 on March 4, 2010 02:53user9027633 wrote:
Select emp_code,
from employee_table where> syntax to add the new column?
Published by: user9027633 on March 4, 2010 02:53
Want you like this
selec emp_code, 0 new_column from employee_table
-
Add the new column on 25 million lines Table
Hi gurus,
I have to add the new column to a populated application table who get to each Transaction.
We can do this with no interruption of service and what are the things that I need to look after adding the peak of performance.
Something happened to my mind is re - run stats
Any Suggestion
Database version = 10.2.0.4
OS = RHEL4
I appreciate your help on this
Thank you789816 wrote:
If the GET of the table is locked, it means that the application cannot write any new transactions in the table until the new default values has been updated?, my understanding of the downtime to do this to*-Online Yes, you need downtime in 10 g *.
Another Question if we have default values as NULL will always be the table get locked?
*-ONLINE YES *.
11 g, this problem has been fixed by oracle: http://www.oracle-class.com/?p=1943
create table sales as select rownum as id, mod(rownum,5) as product_id, mod(rownum,100) as client_id, 2000 as price, to_date( '01.'||lpad(to_char(mod(rownum,3)+1),2,'0')||'.2011','dd.mm.yyyy') as c_date from dual 10 connect by level <= 2.5e5; Table created. SQL> select count(*) from sales; COUNT(*) ---------- 250000 ----session 1 SQL> begin 2 for i in 1..100000 loop 3 insert into sales (id) values(i); 4 end loop; 5 commit; 6 end; 7 / PL/SQL procedure successfully completed. SQL> When inserting into the table sales, the alter table add the new column was waiting for the inserts to finish -----session2: SQL> alter table sales add (provider_id NUMBER(2)); Table altered. SQL>
-
Generate the DDL - change is a new column and I want to generate an alter table.
All, morning
I searched and searched all over the Data Modeler and I can't find this option... but I found it easily in the designer.
I hope you can help me.
V3.0.0.665 SQL Developer Data Modeler.
I added a new column to a table, and when I generate the DDL I wish it were an alter table add column rather than a table to create.
This feature is in the designer, so I think it would be in the Data Modeler.
Just in case my description isn't clear, here are the high level steps, then it is clear.
1 create logic model
2. create the relational logic.
3. create the physical relationship.
4 generate the DDL and run in the database. At this point, I'm going to production with my system, and all right.
5. at this point, we have an enhancement request. For the model, it will be a new column in a table.
6. update of the logic model.
7. relational update logic
8 physical update of relational
9 generate the DDL. Here, I would have generate it know that it needs to generate an alter table add column and does not create the table.
This is something I do a lot as all my models are in production. I can't find how to do this step to get data Modeler to generate the altar.
Designer done exceptionally well.
Quite often, it is more than a single column. Changes can be many and made over time and at the time of generating the DDL you remember not every single amendment. To have the tool discover these changes for you and generate the appropriate DDL is a feature that I consider as very high.
I hope that is clear and you can help me.
See you soon
Chris...Hi Chris,
you need to compare your model on database - database relational model even import and use the option 'swap target' - in this case 'expressions of alter' against the database will be generated.
You can watch demonstrations here http://www.oracle.com/technetwork/developer-tools/datamodeler/demonstrations-224554.html
It would probably be more useful http://download.oracle.com/otn_hosted_doc/sqldev/importddl/importddl.html
Sooner or later your changes will require the table to be recreated, and you will need to backup your data - you can consider using the 'Advanced DDL' option - script is generated that will land your table content (including LOBs) to the system of files accessible from the database and restore after changes. Well not try directly on the production system :).Philippe
-
Hi all
I have tab_trans of transactions table which has nearly 20 million records.
He has entries of all transactions. If any transaction is canceled or partially canceled it also stored there.
To know entirely cancelled transactions currently, we need calculate the sum of the amount of the transaction based on trans_date and trans_id.
To avoid this, I want to add a new column to the table. But it takes a lot of time hell.
This is the structure of the table.
IE > partially/fully cancelled transactions should refresh the rest_amount in the original transaction (where trans_id = 0).Trans_id Trans_date Ref_trans_id Ref_trans_date Trans_amount Trans_ind 10000 2/2/2010 13:12:10 100 0 10001 8/2/2010 12:43:55 300 0 10002 11/2/2010 09:23:24 10000 2/2/2010 13:12:10 -20 1 10003 22/2/2010 10:32:45 10000 2/2/2010 13:12:10 -40 1 10004 23/2/2010 09:45:23 10001 8/2/2010 12:43:55 -300 1 10005 24/2/2010 07:30:23 500 0 So I decided to create a temp_table using CTAS from tab_trans add the rest_amount column and update it with trans_amount in CTAS itself. create table temp_tab_trans as select Trans_id,Trans_date,Ref_trans_id,Ref_trans_date,Trans_amount,Trans_amount rest_amount from tab_trans ; Then I find out the rest_amount using correlated query. update temp_tab_trans a set rest_amount =nvl (select sum(trans_amount) from tab_trans b where b.ref_trans_date=a.trans_date and b.trans_id=a.trans_id),trans_amount) where trans_id=0; My intended result is : Trans_id Trans_date Ref_trans_id Ref_trans_date Trans_amount Trans_ind Rest_amount 10000 2/2/2010 13:12:10 100 0 40 10001 8/2/2010 12:43:55 300 0 0 10002 11/2/2010 09:23:24 10000 2/2/2010 13:12:10 -20 1 -20 10003 22/2/2010 10:32:45 10000 2/2/2010 13:12:10 -40 1 -40 10004 23/2/2010 09:45:23 10001 8/2/2010 12:43:55 -300 1 -300 10005 24/2/2010 07:30:23 500 0 500
After the temp_tab_trans, I create indexes as in tab_trans and deposit of tab_trans and rename temp_tab_trans to tab_trans.
Can I do the update in the ETG itself? Can someone help me...Hello
You can get the sum without a subquery using the analytical SUM function, like this:
CREATE TABLE temp_tab_trans AS SELECT t.* , CASE WHEN trans_ind = 0 THEN SUM (trans_amount) OVER ( PARTITION BY NVL (ref_trans_id, trans_id) , NVL (ref_trans_date, trans_date) ) ELSE trans_amount END AS rest_amount FROM tab_trans t ;
If you wish to post, CREATE TABLE and INSERT statements for your sample data, and then I could test it.
-
SQL: Values in 2 equal columns can highlight text
Hello
I have a report or a statement of pl/sql for a table in which I got a select statement for a table. and i two values in 2 different columns and rows are equal I want to highlite them but I don't know ho to do. I need the solution for both, a simple report and a pl/sql statement
what I have is like that
Col1 - Col2 - Col3 - Col4 - Col5
Col1Val1 Col2Val1 Col3Val1 Col4Val1 Col5Val1
Col1Val2 Col2Val2 Col3Val2 Col4Val2 V a l u e
Col1Val3 Col2Val3 Col3Val3 Col4Val3 Col5Val3
Col1Val4 Col2Val4 Col3Val4 V a u l e Col5Val4
Col1Val5 Col2Val5 Col3Val5 Col4Val5 Col5Val5
Col1Val6 Col2Val6 Col3Val6 Col4Val6 Col5Val6
Col1Val7 Col2Val7 Col3Val7 Col4Val7 Col5Val7
and what I want is
Col1 - Col2 - Col3 - Col4 - Col5
Col1Val1 Col2Val1 Col3Val1 Col4Val1 Col5Val1
Col1Val2 Col2Val2 Col3Val2 Col4Val2 V a l u e
Col1Val3 Col2Val3 Col3Val3 Col4Val3 Col5Val3
Col1Val4 Col2Val4 Col3Val4 V a l u e Col5Val4
Col1Val5 Col2Val5 Col3Val5 Col4Val5 Col5Val5
Col1Val6 Col2Val6 Col3Val6 Col4Val6 Col5Val6
Col1Val7 Col2Val7 Col3Val7 Col4Val7 Col5Val7
thx for your help
concerning
Falk
Published by: Falk on 24.11.2008 06:51Hi Falk,
Add something like the following in the HTML of your page header:
<script type="text/javascript"> function showmatches(f1, f2) { var h1 = document.getElementById(f1); var h2 = document.getElementById(f2); var t = h1.parentNode; while (t.tagName != 'TABLE') { t = t.parentNode; } var rows = t.rows; var k; var j; var headers = t.getElementsByTagName("TH"); var c1; var c2; var i1; var i2; for (k = 0; k < headers.length; k++) { if (headers[k].id == f1) { c1 = k; } if (headers[k].id == f2) { c2 = k; } } for (k = 1; k < rows.length; k++) { i1 = rows[k].getElementsByTagName("TD")[c1].innerHTML; for (j = 1; j < rows.length; j++) { i2 = rows[j].getElementsByTagName("TD")[c2].innerHTML; if (i1 == i2) { rows[k].cells[c1].style.backgroundColor = 'red'; rows[j].cells[c2].style.backgroundColor = 'red'; } } } } </script>
Then add the following text in the footer of the report in your area:
<script type="text/javascript"> showmatches('VALUE3','VALUE4'); </script>
VALUE3 and VALUE4 replacing the names of the columns for the two columns you want to compare.
Finally, you may need to create a new report based on your existing model. In most of those I've been watching, the row front each parameter looks like:
<tr #HIGHLIGHT_ROW#>
You need a model that excludes the #HIGHLIGHT_ROW # this will start by highlighting the lines with your highlight color and you lose the functionality of javascript.
I made a sample page (with a tabular editing page, so you can test changing figures): http://htmldb.oracle.com/pls/otn/f?p=55041:20
Andy
Maybe you are looking for
-
How to open a new tab from the window with a single white (or other)?
I'm embarrassed to ask what should be a simple question. I want to open a new window without containing all of the tabs in my homepage - a single tab, empty, or Mozilla or Google or something. I'm tired of having to close manually the 30 - something
-
Satellite A665 - stop after standby
Hey there,I have a problem: every time if I put my Toshiba Satellite A665 standby and wake him up, everything is normal for 3 seconds. Then the fan starts to work very hard for half a second, then the laptop down computer goeas as if it gets to hot.
-
Initialize the array, then using a feedback node to replace items
Hello friends, I have a typical problem. I need to store values in a table 1 d with 7 elements. I want to start with a set zero array of items. I then start sending values and indices one by one so that the value is inserted in the table and is store
-
I have a perc 5 / i in a poweredge server configured for raid 5. I removed the original diskettes in the table and replaced with expenses records. now I want to put the original disk in the array, but I also expected to keep data that spans the orig
-
3745 router modules replaceable hot?
I would insert a 2FE2W module in a 3745 router in a vacant module slot. Is replaceable to hot or "OIR" online modules, insert and removable capable? Help, please!