SQL & PL/SQL :: Selecting Latest Date

Aug 23, 2012

have a bit of a SQL trouble. I have a simple table (pcuk_BG_alloc_TAB) which stores Parts, Quantities and Applied dates

PART_NO QUANTITY APPLIED
PartA 100 10/8/2012
PartA 200 12/8/2012
PartB 30 12/8/2012
PartC 50 10/8/2012
PartC 75 15/8/2012
PartC 80 21/8/2012

I am only interested the latest applied date for each part and am looking for this to be returned in a select statement (as below)

PART_NO QUANTITY APPLIED
PartA 200 12/8/2012
PartB 30 12/8/2012
PartC 80 21/8/2012

I have tried using the max function (select part_no, quantity, max(applied) from pcuk_BG_alloc_TAB group by part_no, quantity) but seems as the records have different quantities it treats them separately.

View 21 Replies


ADVERTISEMENT

SQL & PL/SQL :: To Retrieve Only Latest Repair Information Based On Latest Date

Apr 3, 2012

I would like to retrieve only the latest repair information based on the latest date regardless of the other information, so I would like to query only items 3 and 5 in the following example.

drop table a;
create table a(
seq number,
custom_id number,
repair_id number,
repair_date date);
[code]........

View 10 Replies View Related

SQL & PL/SQL :: Latest Date (or Max Date) For Consumers

Feb 8, 2007

The oracle table has the following fields,

A_ID, B_ID, CONSUMER_ID, U_DATE, ACTIVE_FLAG.

1 0 111 Jan-02-07 N
1 1 111 Feb-02-07 N
1 2 111 Mar-02-07 Y
1 3 111 Apr-02-07 Y
1 4 111 May-02-07 Y
1 1 222 Feb-06-07 N
1 1 222 Mar-06-07 N
1 1 222 Jun-06-07 Y
1 1 222 Jul-06-07 Y

The table has incorrect data. meaning for each consumer_id we want the ACTIVE_FLAG to be 'Y' only for it's latest record and the rest to be inactive. i.e. we want the data as follows:

A_ID, B_ID, CONSUMER_ID, U_DATE, ACTIVE_FLAG.

A_ID, B_ID, CONSUMER_ID, U_DATE, ACTIVE_FLAG.

1 0 111 Jan-02-07 N
1 1 111 Feb-02-07 N
1 2 111 Mar-02-07 N
1 3 111 Apr-02-07 N
1 4 111 May-02-07 Y
1 1 222 Feb-06-07 N
1 1 222 Mar-06-07 N
1 1 222 Jun-06-07 N
1 1 222 Jul-06-07 Y

View 14 Replies View Related

SQL & PL/SQL :: Having Latest Date

Aug 9, 2013

I have a query where i need to pull back the latest dated record for a tariff

my data looks like

Col_A Col_B Col_C
1| 100 29-Sep-11 Tariff_1
2| 200 24-Apr-12 Tariff_2
3| 300 17-Oct-12 Tariff_3

and i need to add a subquery which pull back the col_c with the larges Col_B i.e i need to pull back tariff_3 only

i tried using a max but dont think that will work.
...
and c.Col_c in ( select col_c where max(col_b))

View 21 Replies View Related

SQL & PL/SQL :: How To Find The Latest Date

Jul 31, 2010

SQL> select * from emp;

SINO BOOK UPDATION_
---------- ---------- ---------
1 UB 01-MAR-10
2 UB 12-MAR-10
3 SB 12-MAR-10
4 DB 12-MAR-10
4 MB 12-JUN-10
4 MB 31-JUL-10

6 rows selected.

SQL> SELECT sino, book, updation_date
2 FROM emp
3 WHERE updation_date IN (SELECT MAX (updation_date)
4 FROM emp
5 GROUP BY book);

SINO BOOK UPDATION_
---------- ---------- ---------
2 UB 12-MAR-10
3 SB 12-MAR-10
4 DB 12-MAR-10
4 MB 31-JUL-10

I would like to know, how to find out the latest date from above query without using group functions like max, min,order by and group by.

View 10 Replies View Related

Query To Get Rows Of Latest Date From Each Group

Aug 9, 2012

I want to get rows by latest date for each group pf rows.

say my data is :

TYPE1 TYPE2 quantity DATE-ORDERED
sweets chocolate 10 05-FEB-2012
sweets chocolate 10 04-DEC-2012
sweets chocolate 10 08-FEB-2012
pastries chocolate 20 08-AUG-2012
[Code] ..........

I want to get results by latest date,
sweets chocolate 10 04-DEC-2012
pastries chocolate 20 08-AUG-2012
sweets vanilla 10 05-DEC-2012
pastries vanilla 20 05-NOV-2012

I have tried Queries with Max(DATE-ORDERED) and grouping it..its not showing me results because I don't have indexes in my data.

View 2 Replies View Related

SQL & PL/SQL :: Query To Get Data For Latest Date For Some Purchases?

Mar 13, 2012

I need a query to get data for the latest date for some purchases.

My expected output would be

Date - Item - Price - Qty
10/6/2011 10129 .5 1
6/8/2011 10130 13.33 9
2/6/2011 10131 21.74 24

Below are the scripts for this.I have also attached it.

CREATE TABLE XX_PO_LINES_ALL
( CREATION_DATE DATE,
ITEM_ID NUMBER,
UNIT_PRICE NUMBER,
QUANTITY NUMBER )

[code]......

View 4 Replies View Related

Selecting All Queries Executed Between Given Date And Now

Oct 26, 2010

Is information in v$sql enough to select all queries executed between given date and now? When the queries are removed from v$sql?

View 1 Replies View Related

Selecting Data From Table On Date Criteria

May 27, 2011

I am new to oracle and have an issue with selecting data from a table on date criteria.

select * from table1 t where t.DT BETWEEN TO_DATE(sysdate-1,'dd/mm/yyyy') AND sysdate

my understanding is that this should give me the data for just one day. but it is not.

What I want is, data for last 30days from today.

View 2 Replies View Related

SQL & PL/SQL :: Selecting Specific Date / Time Range?

May 8, 2013

I want to select a specific date/time range in a query. I want to select from 6 AM yesterday through 6 AM today. I know that CURRENT_DATE - 1 will give me yesterday, and I can search between that and the current_date. However, how do I incorporate the specific time in the query?

View 4 Replies View Related

PL/SQL :: Selecting Missing Date Range With Previous Records Value

Jun 8, 2012

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - ProductionSET DEFINE OFF;
[code]....

10 rows selected.I want the output like as follows, all those missing date i need to carry on the last one's number

  NBR_OF_S   NBR_OF_C S_DATE
---------- ---------- ---------
        34         40 01-MAY-12
        27         29 01-APR-12
        27         29 01-MAR-12
        21         23 01-FEB-12
        21         23 01-JAN-12
        21         23 01-DEC-11
[code]....
       
The date value I have created for this sample is monthly, based on the condition the data value I may need to generate weekly also. That's Monthly or weekly either one.

View 9 Replies View Related

Application Express :: Show Input After Selecting Date In Datepicker?

Jun 11, 2012

I'm using apex 4.1.1 And i want to use a Date Picker item on my page. This works, but.. When a user selects a date you can see the date highlighted. But in the "textarea"corresponding tot the datepicker is not showing the date. This shows the date after clicking the close button.

I would like to show the date directly after selecting a new date.

View 7 Replies View Related

Retrieving Max / Latest Date From A Table With A Join To One Another Table

Sep 19, 2011

I am having trouble retrieving the Max, latest date, from a table with a join to one another table and other fields from both.I was able to get the MAX service_date grouped by id. But once I tried to add more fields to the query and another table it won't work.

Here is what I have:

selectMAX(cs.service_date), cs.notes, cs.applicant_id,wr.program_code,wr.last_name,wr.first_name,wr.region_code,wr.status_cd
from cs join wr on cs.applicant_id=wr.applicant_id
where wr.status_cd='AC'
group by cs.applicant_id

View 3 Replies View Related

PL/SQL :: Selecting Single Record From Multiple Record Based On Date?

Aug 26, 2013

I have a table which contains the multiple records for single ID No. Now i have to select single record which contains the latest date. here is the structure Name  

Null Type  ------ ---- ------------ ID_P        NUMBER       NAME_P      VARCHAR2(12) DATE_P      TIMESTAMP(6) Records---------------------1 loosi     22-AUG-13 01.27.48.000000000 PM1 nammi  26-AUG-13 01.28.10.000000000 PM2 kk        22-AUG-13 01.28.26.000000000 PM2 thej      26-AUG-13 01.28.42.000000000 PM 

now i have to select below 2 rows how can write select qurie for this?

1 loosi 26-AUG-13 01.27.48.000000000 PM2 thej  26-AUG-13 01.28.42.000000000 PM

View 4 Replies View Related

Get Latest Records?

Jun 9, 2011

I have a table that contains history for vehicle positions. In order to find the latest positions quickly, I've included a LATEST column that is 1 if the record is the latest position and 0 otherwise. The table is maintained via a stored procedure. The procedure first sets the latest record for the vehicle to history...

UPDATE vehicle_positions SET latest = 0 WHERE vehicle_id = <vehicle ID> AND latest = 1

It then inserts the new latest record...

INSERT INTO vehicle_positions (vehicle_id, longitude, latitude, insert_time, latest) VALUES (<vehicle_id>, <x pos>, <y pos>, SYSDATE, 1)

Is it possible for me to end up with 2 latest records?Consider this scenario...

Session #1: UPDATE vehicle_positions SET latest = 0 WHERE vehicle_id = 123 AND latest = 1
Session #2: UPDATE vehicle_positions SET latest = 0 WHERE vehicle_id = 123 AND latest = 1
Session #1: INSERT INTO vehicle_positions (vehicle_id, longitude, latitude, insert_time, latest) VALUES (123, 32.8533, -117.1180, SYSDATE, 1)
Session #2: INSERT INTO vehicle_positions (vehicle_id, longitude, latitude, insert_time, latest) VALUES (123, 32.8534, -117.1178, SYSDATE, 1)

I'd end up with 2 latest records. How can I protect against this? I considered using SELECT FOR UPDATE, but seems like there are too many negatives going that route

View 4 Replies View Related

SQL & PL/SQL :: Getting Latest Record From Different Tables?

Feb 4, 2011

I tried to post this issue earlier but it was not very clear. Well. Let me try to put in more better way.I have four tables storing order & customer information.

For given order number and cust _id I need to display latest record. here are my four tables.

SQL> select * from so;
ORD_NO ORD_DATE CUST_ID
---------- --------- ----------
1 01-JAN-10 10
2 02-JAN-09 20
3 03-FEB-11 30

SQL> select * from sol;

FK_ORD_NO FK_CUST_ID CUST_NAME LOCATION
---------- ---------- ------------------------- ----------
1 10 abc MA
2 20 xyz CA
3 30 ijk LA

[code]...

There will be a stored procedure that will take order_no and cust_id as input paremeters and return out ref cursor.

create procedure P1( in_ord_no in number,
in_cust_id in varchar2,
out_cur out sys_refcursor);

Here is the expected output.

Case 1 - in_ord_no =4 , in_cust_id = 10
Expected output - Empty cursor. Because bothe tables does not have matching record.
Case 2- in_ord_no = 3 in_cust_id = 30
Expected output =

[code]...

View 7 Replies View Related

SQL & PL/SQL :: How To Find Last Or Latest Inserted Row

Apr 22, 2013

i have a table in that every month i insert rows and my table doesn't have primary key,index and date filed.for example:-table is like this

name salary Id
john5000101
brat4500102
smith4600103
john5500101
brat4600102
smith4800103

i think one cannot tell in above table whether "john" salary is 5000 or 5500(last insert row is 5000 then john salary is 5000)

when it comes to retrieve i have to pick the latest(last) insert row of particular Name.Is there any auto generated row_numbers in Oracle.

View 1 Replies View Related

Latest Critical Patch Update?

Oct 14, 2010

identify the latest Critical Patch Update for 10g RAC. My DB server is 10g RAC 2 node cluster running on IBM Aix Pseries servers. The version is 10.2.0.3.

View 1 Replies View Related

Download Latest Critical Patches?

May 3, 2011

I want download latest critical patches of 11.1.0.7.0, 11.1.0.6.0. how can i download

View 1 Replies View Related

SQL & PL/SQL :: Updating Table With Latest Record

Mar 17, 2011

DROP TABLE TESTING CASCADE CONSTRAINTS;
CREATE TABLE TESTING
(
DATAPERIOD DATE,
EMPLID VARCHAR2(20 BYTE),
B_OS_REASON VARCHAR2(9 BYTE)
)
TABLESPACE USERS;

[Code] ........

SQL> select * from testing order by 1;

DATAPERIO EMPLID B_OS_REAS
--------- -------------------- ---------
01-OCT-10 2387972
01-NOV-10 2387972
01-DEC-10 2387972 XXXXXX
01-JAN-11 2387972
01-FEB-11 2387972

In the above result, We need to go from bottom up and when we hit some value we need to update with the lastest record as below.("Blank" space are considered as null.)

DATAPERIO EMPLID B_OS_REAS
--------- -------------------- ---------
01-OCT-10 2387972
01-NOV-10 2387972
01-DEC-10 2387972 XXXXXX
01-JAN-11 2387972
01-FEB-11 2387972 XXXXXX

View 5 Replies View Related

How To Export Latest N Records From A Table

Jul 2, 2012

How to export latest n records from a table using the below query(latest n records)

select * from (select empid,ename,sal,joining_date from emp order by joining_date desc) where rownum<n;

View 3 Replies View Related

Installation :: Latest Patchset For 11.2.0.3.0 Windows 64 Bit

Apr 11, 2013

Platform: windows 64 bit
Oracle database 11.2.0.3

I successfully upgraded my database from oracle 11.2.0.1.0 to 11.2.0.3.0 and the upgrade worked fine. I installed the 11.2.0.3.0 in a new oracle home.

Now my task is to install the latest patch set release on the new oracle home(Make database upto date with latest fixes indeed). I am confused with the available documentations in my oracle support.

As CPU is now considered as a subset of PSU patch, i believe i have to apply the latest PSU only.Is this correct? Is there a step by step guide for applying latest patch?I saw there are 5 PSUs released (latest 11.2.0.3.5), do i need to apply each of them or just this final one?

Give me the latest available patchset/patch(Still not clear) install guide and latest available patch download links.

View 3 Replies View Related

PL/SQL :: Latest Salary (last 2 Updated Records)

Jun 18, 2012

I wanted to know the latest salary(last 2 updated records ) getting by emp- id 252 based on below mentioned information

source desti sal emp id MGR
1-Jan 1-Feb 1000 252 venkat
2-Jan 2-Feb 4000 252 venkat
2-Feb 2-Feb 5000 252 venkat

View 4 Replies View Related

SQL & PL/SQL :: How To Get Latest Record In Embedded Select Statement

Mar 12, 2013

I am trying to run an Oracle report with a query that has an embeded sql. this sql is returning more than 1 row, and the report is failing.

I need to pick the latest record entered that this sql return.

I tried rownnum and it works but only i can get the rown num I specify, not the latest record. I try to order, but I am getting an error back.

select w.emp_no, (select t.timestamp
from tob.work_unit t
where t.work_date = to_date('20130312', 'YYYYMMDD')
and rownum = 1
order by t.timestamp desc)
,w. spare_type
from work.work_unit w
where w.work_date = to_date('20130312', 'YYYYMMDD')

I am getting missing right parenthesis at the order by keyword My report is much complex than this, but I am tring to see if I can get the row that I want.

View 10 Replies View Related

SQL & PL/SQL :: How To Select Latest Updated Record From Table

Sep 21, 2011

I want to know like How we can select the latest updated record from xyz table. that record has STATUS column. I also want to check if the status is RED or GREEN query should return if the status is red then 1 and if the status is GREEN then it should return 0

View 8 Replies View Related

Developer Tools :: Can Use Latest Features In Oracle 12c

Oct 2, 2013

I read previous post "Can I use the latest features in Oracle Developer Tools 11g and still use ODP.NET version 10.x or 9.x in my application?".In this the solution was: "Solution: Yes, you can use the newest 11g version of Oracle Developer Tools while developing code that relies on ODP.NET version 10g or 9i. In almost all cases it will work fine. The only exception is with the automatic .NET code generation feature. Here is what you need to do: 

a) Install both ODT 11g  *and* ODP.NET 10g or 9i. They must be placed in different Oracle Homes!
b) You will now be able to use the 11g Oracle Developer Tools for Visual Studio and all of the newest features. To ensure the correct version of ODP.NET is used by your application continue to the next steps:
c)  Make sure that in the "References" section in your solution, the Oracle.DataAccess.dll that is referenced is coming from the Oracle 10 or Oracle 9 Oracle home.
d) Finally, you must "ungac" (gacutil /u) the ODP.NET 11g policy DLL's or else your application will silently begin using the 11g version of ODP.NET even though the reference points to the correct DLL. There are several Oracle policy DLLs with varying names, for example: "Policy.2.102.Oracle.DataAccess.dll". Ungac them all." 

Are the steps the same if i have Oracle Developer Tools 12c and still use ODP.NET version 11g R2 in my application? 

View 1 Replies View Related

SQL & PL/SQL :: Display Date Ranges In One Column As Separate Date Periods (start And End Date) In Two?

Jun 1, 2010

I'm trying to work out how to take a table like this:

IDDate
12502-Feb-07
12516-Mar-07
12523-May-07
12524-May-07
12525-May-07
33302-Jan-09
33303-Jan-09
33304-Jan-09
33317-Mar-09

And display the data like this:

IDPeriodPeriod StartPeriod End
125102-Feb-0702-Feb-07
125216-Mar-0716-Mar-07
125323-May-0725-May-07
333102-Jan-0904-Jan-09
333217-Mar-0917-Mar-09

As you can see, it's split the entries into date ranges. If there is a 'lone' date, the 'period start' and the 'period end' are the same date.

View 13 Replies View Related

Forms :: Expiry Date To Automatically Show A Date 15 Years After Initial Date

Apr 12, 2010

I have a two date fields in my form; valid from date and expiry date.

Currently my valid from date has an inital value property of $$date$$ which automaitcally brings up todays date.

I need my expiry date to automatically show a date 15 years after this date?

View 8 Replies View Related

SQL & PL/SQL :: Taking Latest Current Balance Using Analytical Query

Jan 22, 2013

I am having a table with 5 lakhs transactions. I want to fetch the last balance for a particular date. So i have have returned a query like below.

SELECT curr_balance
FROM transaction_details
WHERE acct_num = '10'

[Code]...

This has to be executed for incrementing of 12 months to find the last balance for each particular month. But this query is having more cpu cost, 12 times it is taking huge time. how to remodify athe above query to get the results in faster way using analytical query. Whether this can be broken into two part in PL/SQL to achive the performance. ?

View 9 Replies View Related

Forms :: Updating Skills From Oracle Developer 6 To Latest

Oct 17, 2012

I have not used Oracle Forms and Reports for some time. The last version I used was Developer version 6.

Has there been major changes between Oracle Developer version 6 and Oracle Developer version 11 or is Oracle Developer basically the same with some incremental improvements? What would be a good way to update my skills from Oracle Developer version 6 and Oracle Developer version 11?

View 1 Replies View Related







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