The most recent data in a table view
I'm adding values to a bulletin board as in the example, but I want to be the most recent data for the user to see the top line.
He keeps adding to the bottom, and then the user will have to Diecut down see all data. Can I select the most recent data somehow or get auto-scrolling data table are applied? I tried registers to shift as well, but no luck.
Here's my VI
Thank you
Mike
Have you read the help of the function insert in the table? He clearly says that if you leave the unwired index entries, it will insert at the end. So, don't let the unwired index entries. Wire a '0' to the row index.
Tags: NI Software
Similar Questions
-
I'm trying to reduce the amount of space that my Windows 7 backup uses so I've come to the place in Windows 7 backup:
Manage space > view backups...I am then presented a list of three backup sets:
01/03/2012 to 01/04/2012
12/07/2011 to 12/21/2011
23/11/2011 to 30/11/2011I would like to remove the older two, leaving the most recent. However, this doesn't seem to work as expected. If I try to delete one of the two most recent ones (the first two in the list above) I get the following warning "Are you sure you want to delete this backup file.
However, if I try to delete the last one in the list, I get a slightly different error "Are you sure you want to remove the most recent data of the file backup?"-sounds strange because it is clearly not the most recent backup according to the dates it's show.
Of course, I can go ahead and ignore the warnings, but I fear that maybe there are some files in the last backup the value in the list that may not be right more recent set backs.
In 2011, I thought this might be something wrong with the date formats vs US UK (I am in England so the above dates are in dd/mm/yyyy format and not in jj/mm/aaaa) - but now it's 2012 and I backup from 2012 and 2011 games and he always seems to think that the oldest backup of 2011 is the most recent.
Any ideas? Can I delete the oldest backup sets (that is, the two that are from 2011) safely?
Any help much appreciated - thank you.
Simon
Update: I checked on other PCs in the office and the situation is the same - is not only something strange on a PC.
-
How to get the values based on the most recent date
Oracle Version 8i
How to get the new_value based on the most recent date
SELECT max (MODIFIED_ON), the Group LOG_ITEM_CHARACTERISTICS by MODIFIED_ON new_value - does not
Please, someone help me
CREATE TABLE LOG_ITEM_CHARACTERISTICS ( CHAR_LOG_ID NUMBER(10) NOT NULL, PIRM_ID VARCHAR2(8) NOT NULL, CONSTANT_FLAG VARCHAR2(1), CHARACTERISTIC_NAME VARCHAR2(25) NOT NULL, TYPE_NAME VARCHAR2(10) NOT NULL, NEW_VALUE VARCHAR2(3000), UOM VARCHAR2(10), MODIFIED_BY VARCHAR2(30), MODIFIED_ON DATE ) SET DEFINE OFF; Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187376, '0307490N', 'N', 'OUTPUT CURRENT', 'PS2030/WVL', '1', 'AMPS', 'EMPXD88', TO_DATE('10/25/1999 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187377, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMPXD88', TO_DATE('09/22/1998 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187378, '0307490N', 'N', 'OUTPUT CURRENT', 'PS2030/WVL', '0', 'AMPS', 'EMDXB88', TO_DATE('09/22/1998 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187384, '0307490N', 'N', 'OUTPUT CURRENT', 'PS2030/WVL', '2', 'AMPS', 'EMAXC29', TO_DATE('11/10/2000 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187385, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55.1', 'VOLTS', 'EMAXC29', TO_DATE('10/19/2001 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_ON) Values (2400742, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '2', 'AMPS', TO_DATE('10/19/2001 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (574093, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '2', 'AMPS', 'EMCTH88', TO_DATE('12/13/2002 11:55:16', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (574094, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMCTH88', TO_DATE('12/13/2002 11:55:16', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (3131486, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '6', 'AMPS', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (3131487, '0307490N', 'N', 'LAST MEASURED DATE', 'PS2030/WVL', '16-12-04', 'DD/MM/YY', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (3131488, '0307490N', 'Y', 'POWER SUPPLY', 'PS2030/WVL', 'ESSENTIAL', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (3131489, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (4759086, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '6', 'AMPS', 'EMRCT88', TO_DATE('11/15/2007 14:33:03', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (4759087, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMRCT88', TO_DATE('11/15/2007 14:33:03', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (4759088, '0307490N', 'N', 'LAST MEASURED DATE', 'PS2030/WVL', '14/11/07', 'DD/MM/YY', 'EMRCT88', TO_DATE('11/15/2007 14:33:03', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6646012, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '5', 'AMPS', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646013, '0307490N', 'Y', 'BATT TEST SET AT 3M', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646014, '0307490N', 'Y', 'CAP ALARM INHIBITED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6646015, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55', 'VOLTS', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646016, '0307490N', 'Y', 'YR ROUTINES REQUIRED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646057, '0307490N', 'Y', 'BATT TEST SET AT 3M', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 13:03:18', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646058, '0307490N', 'Y', 'CAP ALARM INHIBITED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 13:03:18', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646059, '0307490N', 'Y', 'YR ROUTINES REQUIRED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 13:03:18', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6648577, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '6', 'AMPS', 'EMPXD88', TO_DATE('01/07/2011 13:35:45', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6648578, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55', 'VOLTS', 'EMPXD88', TO_DATE('01/07/2011 13:35:45', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6648579, '0307490N', 'Y', 'YR ROUTINES REQUIRED', 'PS2030/WVL', 'NULL', 'EMPXD88', TO_DATE('01/07/2011 13:35:45', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6648580, '0307490N', 'Y', 'BATT TEST SET AT 3M', 'PS2030/WVL', 'NULL', 'EMPXD88', TO_DATE('01/07/2011 13:36:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6648581, '0307490N', 'Y', 'CAP ALARM INHIBITED', 'PS2030/WVL', 'NULL', 'EMPXD88', TO_DATE('01/07/2011 13:36:10', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6648634, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '5', 'AMPS', 'EMPXD88', TO_DATE('01/07/2011 13:51:06', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6648635, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55', 'VOLTS', 'EMPXD88', TO_DATE('01/07/2011 13:51:06', 'MM/DD/YYYY HH24:MI:SS')); COMMIT;
user4587979 wrote:
Hi FrankYes, but I had more than 2 tables with item_characteristics, type_characteristics
If there are other tables involved, then CREATE TABLE and INSERT statements for them (for the relevant columns only). You must not post a lot of examples of data; usually just a couple of lines per table is enough to show the problem.
Also post the results desired from these data.What I try to do is, I'm comparing new_value in log_item_characteristics (whichever is most recent) with CHR_VALUE in the item_characteristics and the needs of different output values
I am trying to query is not giving desired out put
Point out some places where the output is wrong and explain how you get good results in these places, using specific examples from the data sample.
select lic.PIRM_ID, ic.CHR_ID, lic.CHARACTERISTIC_NAME, lic.TYPE_NAME, ic.CHR_VALUE, lic.NEW_VALUE, lic.MODIFIED_BY, lic.MODIFIED_ON, ic.CREATED_BY, ic.CREATED_ON,ic.MODIFIED_BY, ic.MODIFIED_ON from log_item_characteristics lic, item_characteristics ic,type_characteristics tc where lic.TYPE_NAME=tc.TYPE_NAME and lic.CHARACTERISTIC_NAME=tc.CHR_NAME and lic.PIRM_ID=ic.PIRM_ID and tc.CHR_ID=ic.CHR_ID and ic.CHR_VALUE <> lic.NEW_VALUE and lic.pirm_id in ('0307490N','0307521C') order by lic.pirm_id
Thank you; It is useful to see the existing query. Really, you have to format your code.
Please can you help me
What you've posted so far is like saying "I'm going 200 meters to the North, and then 500 meters East, but I'm not getting where I want to go." I would have a better chance to help you if you said, 'I'm out of my house, at 100, Elm Street and try to get to the supermarket at Broadway 279. I'm going 200 meters to the North... ', or, even better. "I want to buy a newspaper and some orange juice, so I thought I'd go to a convenience store. I start at my house, at 100, Elm Street... »
Always post some examples of data (CREATE TABLE and INSERT statements, as you did in your first post) and the desired results from these data. Explain how you get these results from these data. -
The most recent date in the report filter.
Hello
I have a report with a date column. I would like to run the report for the most recent date. I want to add a filter to the report that retrieves data for the latest in date. What would be the best method to use in the filter. Please notify. Thank you.You must first determine what the column that contains the dates on which you want to filter. Say so you have a Date of treatment column containing dates transactions are processed.
(1) add this column in your workspace.
2) click this column filter button, and then click Advanced Options > convert this filter in SQL.
(3) after the name of the column, enter MAX (date_column). So you will have:
"Table name". " "Date column ' = MAX ("Table name". ("' Date column")
Now the chances are that you will have a lot of reports who need the "latest date" filter. Therefore, you should really do is built that filter in the repository and expose it as a filter registered for all to use.
-
Select the most recent DATE for identification.
Hi all
I need to SELECT records with the most recent DATE for each code. A DATE range is part of the selection criteria.
My data.
MY_ID MY_DATE
1684662 26 JANUARY 09
1424097 27 JANUARY 09
1684663 27 JANUARY 09
1684664 27 JANUARY 09
1684672 28 JANUARY 09
0689073 28 JANUARY 09
1052476 21 JANUARY 09
1052476 21 JANUARY 09
1360828 23 JANUARY 09
1684661 23 JANUARY 09
1052476 30 JANUARY 09
1052476 30 JANUARY 09
1052476 30 JANUARY 09
1052476 30 JANUARY 09
The code below works fine when you select 1 ID in the subselect, but with several ID he always selects rownum = 1 (of course). As far my mind takes me.
SELECT my_id,
my_date
Of
(SELECT my_id,
my_date
FROM my_table
ORDER BY DESC my_date
)
WHERE rownum = 1
AND * {color: #ff0000} my_id = 1052476 {color} *.
AND TO_CHAR(my_date,'YYYY/MM/DD') BETWEEN ' 01 / 01/2009 ' AND '' 2009/01/31;
If I could somehow pass the ID SELECT in the subselect WHERE clause I should have done this.
Any suggestions?
Thanks in advance for your help,
LouOne of the many soultions possible.
ME_XE?with data as 2 ( 3 select 1684662 as id, to_date('26-JAN-09','dd-mon-yyyy') as the_date from dual union all 4 select 1424097 as id, to_date('27-JAN-09','dd-mon-yyyy') as the_date from dual union all 5 select 1684663 as id, to_date('27-JAN-09','dd-mon-yyyy') as the_date from dual union all 6 select 1684664 as id, to_date('27-JAN-09','dd-mon-yyyy') as the_date from dual union all 7 select 1684672 as id, to_date('28-JAN-09','dd-mon-yyyy') as the_date from dual union all 8 select 0689073 as id, to_date('28-JAN-09','dd-mon-yyyy') as the_date from dual union all 9 select 1052476 as id, to_date('21-JAN-09','dd-mon-yyyy') as the_date from dual union all 10 select 1052476 as id, to_date('21-JAN-09','dd-mon-yyyy') as the_date from dual union all 11 select 1360828 as id, to_date('23-JAN-09','dd-mon-yyyy') as the_date from dual union all 12 select 1684661 as id, to_date('23-JAN-09','dd-mon-yyyy') as the_date from dual union all 13 select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual union all 14 select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual union all 15 select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual union all 16 select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual 17 ) 18 select id, the_date 19 from 20 ( 21 select id, the_date, max(the_date) over (partition by id) as max_the_date 22 from data 23 ) 24 where the_date = max_the_date; ID THE_DATE ------------------ -------------------------- 689073 28-JAN-0009 12 00:00 1052476 30-JAN-0009 12 00:00 1052476 30-JAN-0009 12 00:00 1052476 30-JAN-0009 12 00:00 1052476 30-JAN-0009 12 00:00 1360828 23-JAN-0009 12 00:00 1424097 27-JAN-0009 12 00:00 1684661 23-JAN-0009 12 00:00 1684662 26-JAN-0009 12 00:00 1684663 27-JAN-0009 12 00:00 1684664 27-JAN-0009 12 00:00 ID THE_DATE ------------------ -------------------------- 1684672 28-JAN-0009 12 00:00 12 rows selected. Elapsed: 00:00:00.03
-
Need help get data with the most recent date of entry into
Hey guys;
I need help with fine tuning a query to get the one with the most recent implementation.
Here's my current query:
/**********************************************
Select sge.seal_group_id,
SGE.equipment_id,
SGE.effective_date
of seal_group_equipment EMS.
seal_group sg
where equipment_id = 48801
AND EMS. SEAL_GROUP_ID = SG. SEAL_GROUP_ID
and sge.end_date is null
Group of sge.equipment_id, sge.seal_group_id, sge.effective_date
After having sge.effective_date = max (sge.effective_date)
******************************************************/
Which produces the following results:
SEAL_GROUP_ID - EQUIPMENT_ID - EFFECTIVE_DATE
25-48801 - 01/01/1993-00: 00:00
11730-48801 - 22/08/2003 08:42:11
What I really need, is to show only the line with the most recent date of entry into
I hope someone can help
Thank youMAX will not work because the SEAL_GROUP_ID could depart. I would say analytical:
select seal_group_id, equipment_id, effective_date from ( select sge.seal_group_id, sge.equipment_id, sge.effective_date, RANK() over (partition by equipment_id order by effective_date desc) r from seal_group_equipment sge, seal_group sg where equipment_id = 48801 AND SGE.SEAL_GROUP_ID = SG.SEAL_GROUP_ID and sge.end_date is null) where r = 1;
Keep in mind if two records have the same effective_date, they would both appear.
Note: query above has not been tested, since there is no script provided.
-
How to find the most recent date prev?
Hello
Here is the sample table and sample data.
I have to read the table so that I got when I read a line of CODE = 1 for DT = 30 - OCT - 2012, I have to check what was the price for the CODE = 1 in the most recent previous date (which is October 28, 2013). Then I will compare the two prices (for 30 Oct 28th) and fill out another table.CREATE TABLE t1 (code NUMBER, dt DATE, price NUMBER) / Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/21/2012', 'MM/DD/YYYY'), 10); Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/22/2012', 'MM/DD/YYYY'), 10); Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/23/2012', 'MM/DD/YYYY'), 12); Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/24/2012', 'MM/DD/YYYY'), 9); Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/25/2012', 'MM/DD/YYYY'), 8); Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/26/2012', 'MM/DD/YYYY'), 13); Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/27/2012', 'MM/DD/YYYY'), 11); Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/28/2012', 'MM/DD/YYYY'), 15); Insert into T1 (CODE, DT, PRICE) Values (2, TO_DATE('10/29/2012', 'MM/DD/YYYY'), 15); Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/30/2012', 'MM/DD/YYYY'), 13); Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/31/2012', 'MM/DD/YYYY'), 13); COMMIT;
I hope I have described the situation well.
Could someone help me with this please?
My actual table contains a few million lines in DEV env and a lot more in PROD.
Thanks in advance!If you use the analytical function LAG you can 'Watch' data of previous lines...
SQL> ed Wrote file afiedt.buf 1 select code, dt, price 2 ,lag(price) over (partition by code order by dt) as prev_price 3* from t1 SQL> / CODE DT PRICE PREV_PRICE ---------- -------------------- ---------- ---------- 1 21-OCT-2012 00:00:00 10 1 22-OCT-2012 00:00:00 10 10 1 23-OCT-2012 00:00:00 12 10 1 24-OCT-2012 00:00:00 9 12 1 25-OCT-2012 00:00:00 8 9 1 26-OCT-2012 00:00:00 13 8 1 27-OCT-2012 00:00:00 11 13 1 28-OCT-2012 00:00:00 15 11 1 30-OCT-2012 00:00:00 13 15 1 31-OCT-2012 00:00:00 13 13 2 29-OCT-2012 00:00:00 15 11 rows selected.
-
How to get data hardbounce retrospective of the most recent date?
I want out of backdata Hard bounce by last date using the API.
Can someone help me?
Any suggestion is appreciated.
Kind regards
Shashi Kant
BLOCK has an API "/ activities" endpoint, you can use to define an excerpt. You can programmatically add a filter him every time you kick off your snippet (something like ActivityDate > = and set the current date as the side right of the > = parameter). You can then use the ' /extracts/
data "endpoint to extract the data returned by eloqua sync. See the documentation for the API BLOCK to get an idea of a typical eloqua extraction process. -
Amount for the most recent date
Hi all
Pls help me to write this query, im using db oracle 11.2. I have a requirement as below
This how my table looks like...
CREATE_DATE LINE_ID QUANTITY
APRIL 1, 2013 10001 1500
APRIL 1, 2013 10001 300
19 APRIL 2013 10001 1500
19 APRIL 2013 10001 300I want that my request to return it...
CREATE_DATE LINE_ID QUANTITY
19 APRIL 2013 10001 1800What is the easiest way to write this query?
Select
Max (create_date) create_date
line_id
, Sum (Quantity) keep (first order by desc create_date dense_rank) AMOUNT
from your_table
Line_id group
CREATE_DATE LINE_ID QUANTITY
19.04.2013 "10001" "1800".
-
Application of most recent date...
Hi all..
I noticed 2 tables and sub_note and sample data is...
How can select the most recent date of product and the more recent date for the expectations... to join these 2 tables of...create table note(note_date date,pmry_id number,sub_id number not null) insert into note(note_date,pmry_id,sub_id) values('12/30/2008 02:12:52',282,1) insert into note(note_date,pmry_id,sub_id) values('12/23/2008 10:12:24',282,1) insert into note(note_date,pmry_id,sub_id) values('12/22/2008 01:12:11',282,1) insert into note(note_date,pmry_id,sub_id) values('12/22/2008 09:12:56',282,1) insert into note(note_date,pmry_id,sub_id) values('12/19/2008 01:12:54',282,1) insert into note(note_date,pmry_id,sub_id) values('12/22/2008 09:12:56',282,2) insert into note(note_date,pmry_id,sub_id) values('12/22/2008 09:12:57',282,2) create table sub_note(sub_id number not null,sub_name varchar2(100)) insert into sub_note(sub_id,sub_name) values(1,'Product') insert into sub_note(sub_id,sub_name) values(2,'Expectations')
Thanks in advance...Hello
Use MAX and GROUP BY:
SELECT sn.sub_name , MAX (n.note_date) AS latest_note_date FROM note n JOIN sub_note sn ON n.sub_id = sn.sub_id WHERE n.sub_name IN ('Product', 'Expectations') GROUP BY sn.sub_name;
-
Windows 7 photo order oldest to the most recent
Unable to display my photos in chronological order taken. They default to the most recent date but not on the closest date
You can do a right click on the background of the white paper and click Sort by and use ascending or descending.
-
BlackBerry Email view - jump to the most recent smartphones?
HI - how can I get to the top (most recent) page email in my Inbox? Every now and then I'll open my Inbox and weeks or months email is highlighted. Then, to return to the most recent email, I carried on the wheel. It MUST be a simple combination of keys to jump to the top. Thank you!
-
How to find the most recently read or access files or documents.
In XP, there is a choice of the icon when you open start botton for the most recently viewed or read files. Once again, I would like this feature. How?
Currently, I click on start, then the documents, and the only choice which is "recently changed". This choice is usually useless for me. Thank you
Windows, which fell in the start menu because now you can pin programs to the start menu and programs have separate to show their recent files in the same kind of drop-down menu, then it has become redundant.
In the same start menu list watch the privacy section and check the two options and apply.
Once these programs are on the list of the start menu, make a right click and select PIN to start menu, all recent item will be on this list and can be pinned to this list.
You can also drag and pin programs to the taskbar as well.
Also if you want an option to see recently changed items, open your library and on the top of the left column is changed recently listed, click with the right button on this list, select send to and click on create the shortcut on the desktop, once on your desktop you can drag to your taskbar or just leave it there change the display of this page and the dates of changes will be listed.
-
Performance of the queries in order to get the most recent price
Happy new year everyone.
I have a table of price in my system that has several awards for each product with the date, the price is entered into force.
I have queries throughout the system to retrieve the most recent actual price for the date of the transaction.
I can find to implement the easiest way is to have a user-defined function to collect the prize.
My problem is that many of my questions have access to large amounts of data (for example, transactions) and my table of prices is also big enough - both have millions of records. Using a Pl/SQL function defined by the user in my query, I get a lot of switching context between SQL and PL/SQL and my questions are not well
Here is an example of code, which simplifies my scenario:
drop table xo_stock_trans; create table xo_stock_trans (item varchar2(25), trans_date date, quantity number(20,4)); insert into xo_stock_trans values('A',TO_DATE('25-DEC-2014','DD-MON-YYYY'), 4); insert into xo_stock_trans values('A',TO_DATE('27-DEC-2014','DD-MON-YYYY'), -2); insert into xo_stock_trans values('A',TO_DATE('28-DEC-2014','DD-MON-YYYY'), 5); insert into xo_stock_trans values('B',TO_DATE('23-DEC-2014','DD-MON-YYYY'), 20); insert into xo_stock_trans values('B',TO_DATE('26-DEC-2014','DD-MON-YYYY'), -6); insert into xo_stock_trans values('B',TO_DATE('29-DEC-2014','DD-MON-YYYY'), 15); / -- Generate lots more data BEGIN -- Generate more trans dates for r in 1..1000 LOOP insert into xo_stock_trans select item, trans_date - r - 7 as trans_date, ROUND(dbms_random.value(1,50),2) as quantity from xo_stock_trans where trans_date between TO_DATE('23-DEC-2014','DD-MON-YYYY') AND TO_DATE('29-DEC-2014','DD-MON-YYYY') and item in ('A','B'); END LOOP; COMMIT; -- generate more items for lt in 1..12 LOOP -- generate C,D, E, items INSERT into xo_stock_trans SELECT chr(ascii(item)+(lt*2)) as item, trans_date, quantity from xo_stock_trans where item in ('A','B'); -- generate A1, A2, B1, B2, etc for nm in 1..10 LOOP INSERT INTO xo_stock_trans select item || to_char(nm), trans_date, quantity from xo_stock_trans where length(item) = 1; END LOOP; COMMIT; END LOOP; COMMIT; END; / create index xo_stock_trans_ix1 on xo_stock_trans (item); create index xo_stock_trans_ix2 on xo_stock_trans (trans_date); exec dbms_stats.gather_table_stats(ownname =>user, tabname => 'XO_STOCK_TRANS' , estimate_percent => 100, degree => dbms_stats.auto_degree, cascade=>true); / drop table xo_prices; create table xo_prices (item varchar2(25), price_date date, gross_price number(20,4), net_price number(20,4), special_price number(20,4) ); insert into xo_prices values ('A', to_date('01-DEC-2014','DD-MON-YYYY'), 10, 8, 6); insert into xo_prices values ('A', to_date('25-DEC-2014','DD-MON-YYYY'), 9, 8, 6); insert into xo_prices values ('A', to_date('26-DEC-2014','DD-MON-YYYY'), 7, 6, 4); insert into xo_prices values ('B', to_date('01-DEC-2014','DD-MON-YYYY'), 5.50, 4.50, 3); insert into xo_prices values ('B', to_date('25-DEC-2014','DD-MON-YYYY'), 5.00, 4.00, 3); insert into xo_prices values ('B', to_date('26-DEC-2014','DD-MON-YYYY'), 3.50, 2.50, 2); / -- Generate lots more data BEGIN -- Generate more price dates for r in 1..1000 LOOP insert into xo_prices select item, price_date - r - 7 as price_date,gross_price, net_price, special_price from xo_prices where price_date between TO_DATE('23-DEC-2014','DD-MON-YYYY') AND TO_DATE('29-DEC-2014','DD-MON-YYYY') and item in ('A','B'); END LOOP; COMMIT; -- generate more items for lt in 1..12 LOOP -- generate C,D, E, items INSERT into xo_prices SELECT chr(ascii(item)+(lt*2)) as item, price_date, gross_price + (lt*2), net_price + (lt*2), special_price + (lt*2) from xo_prices where item in ('A','B'); -- generate A1, A2, B1, B2, etc for nm in 1..10 LOOP INSERT INTO xo_prices select item || to_char(nm), price_date, gross_price, net_price, special_price from xo_prices where length(item) = 1; END LOOP; COMMIT; END LOOP; END; / create index xo_prices_ix1 on xo_prices (item, price_date); exec dbms_stats.gather_table_stats(ownname =>user, tabname => 'XO_PRICES' , estimate_percent => 100, degree => dbms_stats.auto_degree, cascade=>true); / create or replace function xo_get_price(I_Item in VARCHAR2, I_Date in DATE, i_Price_type IN VARCHAR2) RETURN NUMBER IS -- Function to get most recent effective price prior to the date CURSOR c_get_prices(P_Item VARCHAR2, P_Date VARCHAR2) IS SELECT gross_price, net_price, special_price FROM XO_PRICES WHERE item = P_Item AND price_date <= P_Date ORDER BY price_date desc; -- most recent price l_gross_price NUMBER(20,4); l_net_price NUMBER(20,4); l_special_price NUMBER(20,4); BEGIN OPEN c_get_prices(I_Item, I_Date); FETCH c_get_prices INTO l_gross_price, l_net_price, l_special_price; CLOSe c_get_prices; IF I_Price_Type='GROSS' then return l_gross_price; ELSIF I_Price_Type= 'NET' then return l_net_price; ELSIF I_Price_Type= 'SPECIAL' then return l_special_price; END IF; END xo_get_price; / -- Here is a typical query I am trying to perform select tr.item, tr.trans_date, tr.quantity , xo_get_price(tr.item, tr.trans_date, 'GROSS') as gross_price , xo_get_price(tr.item, tr.trans_date, 'NET') as net_price , xo_get_price(tr.item, tr.trans_date, 'SPECIAL') as special_price from xo_stock_trans tr where tr.trans_date between '01-AUG-2014' and '31-AUG-2014';
I would like to refactor my request so that I do not use the user Pl/SQL functions, but so far I can't get something that works better than the SQL above. For example, the following query is MUCH longer:
select tr.item, tr.trans_date, tr.quantity , pr.gross_price , pr.net_price , pr.special_price from xo_stock_trans tr join xo_prices pr on pr.item = tr.item and pr.price_date = (select max(pr2.price_date) from xo_prices pr2 where pr2.item = pr.item and pr2.price_date <= tr.trans_date ) where tr.trans_date between '01-AUG-2014' and '31-AUG-2014';
I'm interested to know if anyone has addressed a similar scenario and have managed to write more efficient code.
I looked at the determinism/manual caching of the function, but the article/date combinations are quite unique and therefore he does not benefit from him.
Any suggestion under review - parallelism, analytical, pipeline functions, etc.
Alan
Hi, Alan.
Alan Lawlor wrote:
...
My problem is that many of my questions have access to large amounts of data (for example, transactions) and my table of prices is also big enough - both have millions of records. Using a Pl/SQL function defined by the user in my query, I get a lot of switching context between SQL and PL/SQL and my questions are not well...
You got that right! User-defined functions can be very practical, but this practice comes with a price.
What version of Oracle are you using? The Oracle 12, there is a new feature of 'temporal validity' which may help you.
In any version, it will be much faster if you add a new column to the xo_prices table. You can call this end_date, although it would in fact be the date when some other prices took effect. You might put DATE' 9999-12-31 in the column end_date for current prices. You can calculate end_date using the analytical function of LEAD. Be sure to re-calcluate end_date when you insert new rows into xo_prices, or when you update the dates on existing lines.
Once you have PRICE_DATE and end_date in the XO_PRICES table, you can join this table to get the real price from d by including
AND d > = xo_prices.price_date
AND d< > >
in the join condition.
In some situations, especially when you don't have much different (item, dates) combinations, scalar-sub-queries could be faster than joins.
Whatever it is, it participates without PL/SQL, so there is no context switching.
-
Return the most recent line with analytics
Hi all
Let's say I have this kind of 2 tables:
(People) CREATE TABLE
ID NUMBER,
name VARCHAR2 (128));
INSERT INTO persons VALUES (1, 'Ted');
INSERT INTO persons VALUES (2, 'John');
(Grade) CREATE TABLE
people_id NUMBER,
title VARCHAR2 (128).
START_DATE DATE);
INSERT INTO rank VALUES (1, 'Private', to_date('03-09-1980','DD-MM-YYYY'));
INSERT INTO rank VALUES (1, 'First Class', to_date('25-03-1982','DD-MM-YYYY'));
INSERT INTO rank VALUES (1, 'Sergeant', to_date('22-08-1989','DD-MM-YYYY'));
INSERT INTO rank VALUES (2, 'Sergeant', to_date('07-09-1987','DD-MM-YYYY'));
INSERT INTO rank VALUES (2, 'Lieutenant', to_date('17-05-1995','DD-MM-YYYY'));
What would be the way smart to find the last year of all the people?
Now, I would do something like this:
WITH tmp AS)
SELECT
people_id
title
DENSE_RANK() over (PARTITION BY people_id ORDER BY start_date DESC) history
GRADE
)
SELECT
People.Name, tmp.title
Of
LEFT JOIN tmp WE the people (people.id = tmp.people_id AND tmp.history = 1)
;
Result:
NAME TITLE -------- -------------------------
Ted Sergeant John Lieutenant Is there a smarter way to do it?
In particular, is there a way to return only the most recent (or older) line a table? (I tried the FIRST clause without success...)
Thank you!!
It will work for your example. More generally you would probably group by id and then just drag the columns id that show you (in case you had two Teds, for example)
SELECT title of the Dungeon (dense_rank last order by start_date) p.name, max (title)
class g
join in-house people p on g.people_id = p.id
Group p.name;
Maybe you are looking for
-
By connecting to a Web site, fill my email address and when you enter my e-mail address in a field when making a purchase online I use an e-mail address that begins daowens@--- The name dawns@--- replaces daowens@--- I noticed while typing the addres
-
You are not on the latest version of Firefox. Update today to get the best of the Web!Above is the message I get on my home page. The upgrade is highlighted today and when I click it I go to the Firefox page, and this page shows that I'm on the lates
-
Satellite P50-B-10Z and official Windows 7
The laptop comes with windows installed 8.1 factory, but I wish I am trying to downgrade the OS, can I get a free official copy of the operating system Windows 7 and key to toshiba?
-
When I try to access Google I get a not found message "404" this never happened before
Same thing with 'Bling '.
-
problem with high CPU usage audiodg.exe
While playing the game, I get a message saying that I raised the CPU usage 99% of the base. This is caused by "audiodg.exe. I tried a few bugs that I found online. I was told that they would not work with my computer. I have a Dell XPS15 second-gener