Select the last disk in the history table
How to select the last record in a history table? the example data is< p >
Product EffectiveDate
prod1 01/01/1980
prod1 01/01/1990
prod1 01/01/2000
prod2 02/02/1980
prod2 02/02/2000
< /p >
< p >
The expected result is
Product EffectiveDate
prod1 01/01/2000
prod2 02/02/2000
< /p >
Assuming that there is a single line with max (effectivedate) for a given product
SELECT product, attrib1, attrib2, ... , max_effective_date
FROM (SELECT product,
attrib1,
attrib2,
... ,
effectivedate,
max( effectivedate ) over (partition by product) max_effective_date
FROM history_table)
WHERE effectivedate = max_effectivedate
should work.
Justin
Published by: Justin cave on October 30, 2008 18:32
Formatting changes
Tags: Database
Similar Questions
-
Select the string table drop-down list box.
Hi all
I want to select the combo box list based on a string in the entry, I don't know how to do this. I have a drop-down list box and the value comes from a database, what I want to do is I want to change the value of the selected box based on the existing value in the database drop-down list. for example, A, B, C D I strings in the drop-down list box, and then in my database, I have a field with the string C, I want to change the C to A. I can't enter the value of C in a string format, but I don't know how to be the first position of the drop-down list box in so the order of channels combo box will be C, A, B, d., the value of C
Thank you
Then just write a new array of strings, with the elements of the new agenda, to the "[] strings" - property.
Either you must code something that allows you to create an array of strings with the elements in the order that you want them to be. If there is a reorganization only, you could do something like:
-Get the array of strings [] from the drop-down list using a property node box.
-Find the position of the element you want to place first and use "delete from table", which returns the new array and the element removed.
-Build a new table 1 d of the deleted item and table remaining. Move to the second combobox Strings [] property of a node property.
-
Need to create the Partition in the history table
Hello
I have an audit table that stores the data for the last 8 years in it and the customer wants to retain the data for the last 8 years. Now as adding data to this table is increasing, there is a delay in execution of report which are acquired by querying on this table.
Basically, they go a from date and to date. Then these date are compared with two columns of dates in the table. The condition of the query will be as below
TRUNC (NVL (DATE1, DATE2)) > = TRUNC (TO_DATE (?, ' dd/mm/yyyy ""))
AND TRUNC (NVL (DATE1, DATE2)) < = TRUNC (TO_DATE (?, ' dd/mm/yyyy ""))
Users can query for any date range.
I am thinking of creating a Partition of the range on this table for each month during the 8 years of data. Please suggest on the question of whether I should use partition interval range to make it more effective. And would also create an Index on this partition for the above two day columns.
12 (months) SO * 8 (years) = 98 would be created partitions. This will not overload the schema of database/Tablespace? Y at - it another effective way to set the table.
Please suggest and let me know for any clarification.
There are 2 approaches (but not limited to 2) to create the Partition on an existing table:
Note: There is no ALTER TABLE statement to convert a heap table to a partitioned table.
1. create a temporary Partitioned table with the same types of data in the column. Take a dump of the original table (HEAP) export and import the dump into the newly created partitioned intermediate table. After checking the data file the original and rename the interim even as the original table.
2 using the package Oracle DBMS_REDEFINITION automates the steps above from said (not exactly the same steps, however) and its done online - which means there is no required downtime, the original table may undergo DML operations during this process of redefinition. View partitioning of a table online with DBMS_REDEFINITION | Oracle instructor
According to my understanding if let us know as a partition interval then in April if there is an inserted record then it will create a new partition for the month of April will be of value less than 30 April 2014 "and all other documents created in April will pass under it"
Yes, it's a feature of 11g, which Oracle manages adding partitions as needed. In earlier versions DBA can add partitions manually from time to time. Reference www.gavinsoorma.com/2009/09/11g-interval-partitioning/
Here the reason for check the sent_out_datetime NVL will be NULL for few records, so in this case we want to get the records for dates of mapping them to received_datetime
In addition, try to replace the NVL with COALESCE and test it. This would help improve performance.
-
Select the audit Tables?
Hello
I think I know the answer to this one...
Is there anyway to audit the DB users select a table?
i.e.
In the same way that a person can create a trigger on a table whose fires on insert, delete or update you can audit on choose?
Thanks for your time,
Robert.Select audit on tbl per session;
SY.
-
I want to select catid of an test_classent_list object but fail to do so. Can you help me please? I would avoid iteration in the list one by one.
create type test_cat as object ( catid varchar2(20) ); create type test_classent as object ( cat test_cat ); create type test_classent_list as table of test_classent; --works: select cat from table(test_classent_list(test_classent(test_cat('1')),test_classent(test_cat('2')))); --does not work: select cat.catid from table(test_classent_list(test_classent(test_cat('1')),test_classent(test_cat('2'))));
You must use a table alias when you want to do something like this:
SQL> select t.cat.catid from table(test_classent_list(test_classent(test_cat('1')),test_classent(test_cat('2')))) t; CAT.CATID -------------------- 1 2
-
Select the entire table in the procedure
I want to create a procedure that selects all rows in the object with the following select statement:
SELECT r.firstname, r.lastname,
r.Address.streetname, r.address.city.postalnumber, r.address.city.cityname,
(SELECT t.phonenumber
Channels3 p, of the table (p.phonelist) t WHERE deref (t.phonetype) .phonetypename = "passenger".
AND (p) REF = REF (r)
) as passenger.
(SELECT t.phonenumber
Channels3 p, of the table (p.phonelist) t WHERE deref (t.phonetype) .phonetypename = "mobile"
AND (p) REF = REF (r)
) as mobile,.
(SELECT t.phonenumber
Channels3 p, of the table (p.phonelist) t WHERE deref (t.phonetype) .phonetypename = "percentages".
AND (p) REF = REF (r)
) as Naing
From channels3 r
but I don't know how to do it correctly. Can someone tell me how can I do this? THXyou would need a refcursor.
create or replace procedure my_proc(pRc out sys_refcursor) as begin open pRc for select * from person; end;
call this in c# code. You can store the result in a DataSet.
-
Oracle Application Express relaxing select the database table?
Hi all
I use Oracle Application Express. I created a page and I want to fill the 2 (txtname, txtaddress1) on my page when the user provides no Id on another field (txtID).
Can someone help me please how to do this?
Thank you very much
Gunajee.Hello
There are 3 ways to meet your needs
1 goto your article > Source > Source: always... > Type of Source: SQL returns a single value > Source value or expression: select column_value from table_name where pk =: pk_item
2 create a calculation
The rendering of Page Goto > calculation.Create calculations > on this Page >. . follow the instructions in the wizard and set required values.
3. create a dynamic action (a better and simpler)
The rendering of Page Goto > Dynamic Actions.create dynamic Actions > on item1 > when changed > value > sql statement > write the sql query > done point > required element (item2)
fire on loading the page: uncheck
Note: For 1 and 2, you need to send the page.
You can use {'code'} {'code'} to keep your code. (remove the apostrophes and use)
Kind regards
Little Foot -
Day of the history tables track Oracle HRMS &; discoverer
Hello experts,
I will be happy if someone can help through. I am elaborating the report SAY end of audit following any changes entered by data entry officers, regardless of the date of entry in. Mainly of the person and the assignment form.
Is there anyway that I can include the date / time of change fact/status updated. Is the index "actual date"?
for example, there is a change of employment - organization 'Global Operations' organization 'domestic Application. The change is supposed to be beginning from 05/02/2011, but I'm in action 18/04/2011. Similar to past events - if I do date on caterpillars change assignment suppose to be effective from 04/04/2011.
How can I stay in a report. I have just the FINAL of Discoverer10g user license rights. (Oracle R12)
Thank you very much.Hi Neha
No problem. When you get a chance, could you please tag my answer as being correct so that it will help others?Best wishes
Michael -
Insert data. Select the sequence ID, but popuate even value for two different columns
Hello
Version Oracle 11 G
[code]
CREATE TABLE MT_PROGRAM
(
NUMBER OF "PROGRAM_ID."
NUMBER OF "REPORTING_PROGRAM_ID."
'PROGRAM_NAME' VARCHAR2 (128 BYTE)
);
INSERT INTO MT_PROGRAM)
PROGRAM_ID,
REPORTING_PROGRAM_ID,
PROGRAM NAME)
SELECT PROGRAM_ID,
PROGRAM_ID,
PROGRAM NAME
Of
(SELECT
fn_get_new_prog_id() AS PROGRAM_ID,
'Test' as the program name OF THE DOUBLE);
The function has
create or replace
FUNCTION "FN_GET_NEW_PROG_ID".
RETURN NUMBER
AS
BEGIN
RETURN SQ_PROG_ID. NEXTVAL;
END;
[/ code]
Problem is that I must get
I need Reporting same Program ID ID program and the same sequence. But here I am ecstasy. For example, if my sequence is from 1 then it inserts
1, 2, 'test '.
But I need
1, 1, 'test '.
P.S. I can't not 1 insert unwanted accounting value of the program and of the update the program id. I have a trigger on the table which keeps track of each insert, update. And I don't want to use the separate update statement because it will create additional row in the history table.
SQL > create the sequence Tessai minvalue maxvalue 1 99999999999999999 with increment of 1 by 1 cover 2;
Order of creation
SQL > select ttest.currval from double;
Select double ttest.currval
ORA-08002: sequence TESSAI. CURRVAL is not yet defined in this session
SQL > select ttest.nextval from double;
NEXTVAL
----------
1
SQL > select ttest.currval from double;
CURRVAL
----------
1
SQL > select ttest.nextval from double;
NEXTVAL
----------
2
SQL > select ttest.currval from double;
CURRVAL
----------
2
SQL >
I have it?
----
Ramin Hashimzade
-
Two filters in two dimensions without constraining the fact table
Hi all
does anyone know how to avoid the factual constraint when you create a report with two filters on different dimensions?
I have a fact table big with more than 10 million lines. In the starmodel is the customer of the dimension and the products. I create a filter on the customer atrribute 'Status' and set to 'active '. Now I add the "Product Type" column of the dimension 'Product' in the filter section. When I want to choose a value OBIEE executes a select statement in the fact table. So I have to wait very long to select a value. Is it possible to say OBIEE only to select the dimension table without joining the fact table?
Thank you much in advance.
Kind regards
StefanUse is implied.
Create a table of facts of the DUMMY and make also implied made for this dimension column. It will solve the problem.
http://obiee11gqna.blogspot.com/2011/01/implicit-fact-column-in-OBIEE.htmlPublished by: MK on January 17, 2012 07:08
Published by: MK on January 17, 2012 07:08
-
Select the last 10 records in a table
Oracle9i. I am trying to select the last 10 numbers in a table with this command series
but it's not not selecting the most recent serial number 10. How to do?select serial from tab_42 where employeecode='00001' and rownum<=10 order by serial desc;
The rownum clause is applied before the order by clause, one must use a subquery...
select * from (select serial from tab_42 where employeecode='00001' order by serial desc) where rownum<=10;
-
How to select the last 3 records in a table?
I have a table named HRM_ATTENDANCE
as follows
the table contains the record of leave of employees as followsName Type Nullable Default Comments ------------ ------------ -------- ------- -------- LEAVEDATE DATE EMPLOYEECODE VARCHAR2(8) LEAVETYPE VARCHAR2(4) APPROVEDBY VARCHAR2(8) Y FEEDBY VARCHAR2(8) Y FEEDTIME DATE Y REMARKS VARCHAR2(50) Y
I want to select the last 3 leaves (records) to employeecode "00001" so I don't know the what are the dates of the leave. in easy words I want to choose the folder where leavedate > = 5 June 2013 ", but I don't know any dates."LEAVEDATE EMPLOYEECODE LEAVETYPE APPROVEDBY FEEDBY FEEDTIME REMARKS ----------- ------------ --------- ---------- -------- ----------- -------------------------------------------------- 6/1/2013 00001 CL 6/3/2013 00001 EL 6/5/2013 00001 CPL 6/7/2013 00001 SL 6/9/2013 00001 CL
Select * from HRM_ATTENDANCE where rownum<=3 order="" by="" leavedate="">=3>
-
By selecting the last row of the table
I'm trying to select the last row in a table. The tables will have a different number of lines, so I can't select based on a line number. I tried to use the location options, but get an error that "the object is not a function". Not sure what the problem is.
table = app.selection[0]; if (table.hasOwnProperty("baseline")) table = table.parent; if (table instanceof Cell) table = table.parent; if (table instanceof Column) table = table.parent; if (table instanceof Row) table = table.parent; if (table instanceof Table) { table.rows(LocationOptions.AT_END).cells.texts.everyItem().fontStyle = "regular"; }
You can use the placement options for this?
Hello
table. Rows being a collection of object using the index-[1] is a proper way
but cells.texts generates an error. Change it to:
table.rows[-1].cells.everyItem().texts.everyItem().appliedCharacterStyle = "myriad regular";
Jarek
-
How to select the last 20 transactions in a table
Hi guys,.
I have a table named INOUT with following columns
EMPLOYEECODE VARCHAR2
DATE OF THE RESPONDENT
each day employees now their me 'in '. then entered came and came in this table. If we want to select the last 20 EMPLOYEECODE in this table that make their selves 'in '. How to choose that? just 20 last employees who traded. Help, pleaseHello
This is called a Query Top - N , you want to choose elements of N (N = 20, in this case) from the top of a sorted list.
Here's a way to do it:WITH got_r_num AS ( SELECT emloyeecode , MAX (intime) AS latest_intime -- If wanted , RANK () OVER (ORDER BY MAX (intime) DESC) AS r_num FROM inout GROUP BY employeecode ) SELECT employeecode , latest_intime -- If wanted , r_num -- If wanted FROM got_r_num WHERE r_num <= 20 ;
That actaully could take more than 20 people: If there be a tie, it includes any person who is entitled to be in the top 20. If you want exactly 20 people, then add the columns of tiebreaker to analytical or use ROW_NUMBER instead of RANK ORDER BY clause.
-
Select the last value for each day of the table
Hello!
I have a table that contains several measures for each day. I need two queries on this table, and I'm not sure how to write them.
The table stores the rows (sample data)
Explanation of the data in the sample table:*DateCol1 Value Database* 27.09.2009 12:00:00 100 DB1 27.09.2009 20:00:00 150 DB1 27.09.2009 12:00:00 1000 DB2 27.09.2009 20:00:00 1100 DB2 28.09.2009 12:00:00 200 DB1 28.09.2009 20:00:00 220 DB1 28.09.2009 12:00:00 1500 DB2 28.09.2009 20:00:00 2000 DB2
We measure the size of the data files belonging to each database to one or more times a day. The value column indicates the size of the files of database for each database at some point (date in DateCol1 European model).
What I need:
Query 1:
The query must return to the last action for each day and the database. Like this:
Query 2:*DateCol1 Value Database* 27.09.2009 150 DB1 27.09.2009 1100 DB2 28.09.2009 220 DB1 28.09.2009 2000 DB2
The query should return the average measurement for each day and the database. Like this:
Could someone please help me to write these two queries?*DateCol1 Value Database* 27.09.2009 125 DB1 27.09.2009 1050 DB2 28.09.2009 210 DB1 28.09.2009 1750 DB2
Please let me know if you need further information.
Published by: user7066552 on September 29, 2009 10:17
Published by: user7066552 on September 29, 2009 10:17Why two queries when it suffice ;)
SQL> select dt 2 , db 3 , val 4 , avg_val 5 from ( 6 select dt 7 , val 8 , db 9 , row_number () over (partition by db, trunc (dt) 10 order by dt desc 11 ) rn 12 , avg (val) over (partition by db, trunc (dt)) avg_val 13 from test) 14 where rn = 1 15 order by dt 16 / DT DB VAL AVG_VAL --------- ----- ---------- ---------- 27-SEP-09 DB2 1100 1050 27-SEP-09 DB1 150 125 28-SEP-09 DB2 2000 1750 28-SEP-09 DB1 220 210
Maybe you are looking for
-
I used to be able to change the display of the icon in the section Customize.
At the bottom of the screen to the icons, you can move the toolbars, there was an option to display icons only or icons and text. What's the version 29 Also, where is the button reload?
-
Skype install 6.22.81.105.msi
I would appreciate a link to download the installer of Skype 6.22.81.105.msi thanks and regards, Roy
-
pushGlobalScreen(), I'm doing something wrong?
Hi all I got this simple piece of code that I expect to work, but it does not have anything on the screen. I have an application that extends the Application, running in the background.like this Class BackgroundTask extends Applicaition{ public stati
-
Adobe Lightroom CC (2015) of the trial does not start
The 30 day trial of Adobe Lightroom CC (2015) earlier today, I installed and it did not work at all. Whenever I open the app, a 30 second video appears and covers the screen. I can't close the video, and whenever I click on play, the video does nothi
-
Styles inline does not display in Design view after update (Mac)
I use DW to create HTML emails that rely on tables for page layout styles and online for the appearance. After the recent update, none of my inline styles are in Design mode. It is a puzzle. The reason I use DW is to see what I'm doing visually.Every