Oracle Maximum Date Query
i need assistance in creating a query
select a.job_number, a.title, a.request_date, a.completion_date, b.modification_number,b.actual_cost, b.shop_facility_percentage, d.status_date
from
survey_jobs a
left outer join survey_job_bundles b
on (a.survey_job_id = b.survey_job_id)
left outer join survey_job_status d on (b.survey_job_bundle_id = d.survey_job_bundle_id)
order by a.job_number asc, b.modification_number asc
this query produces a report that duplicates some of the rows. it does this because i am joining to a child to table that has a one to many relationship with its parent. The child table can have many dates (d.status_date). I want to pull the maximum date from this child table. I have created a max function that i was trying to plug in, but when i plug it in right under the last outer join, it reduces my report results.
here is my attempted max function
AND b.SURVEY_JOB_BUNDLE_ID = d.SURVEY_JOB_BUNDLE_ID
AND ((d.SURVEY_JOB_BUNDLE_ID IS NULL) OR
(d.SURVEY_JOB_BUNDLE_ID, d.STATUS_DATE) IN
(SELECT SURVEY_JOB_BUNDLE_ID, MAX(STATUS_DATE) FROM
SURVEY_JOB_STATUS GROUP BY SURVEY_JOB_BUNDLE_ID))
Can anyone help me with this? Thanks in advance
Edited by: 963510 on Jan 9, 2013 11:17 AM
Edited by: 963510 on Jan 9, 2013 11:22 AM
Edited by: 963510 on Jan 9, 2013 11:23 AM
GROUP BY the maximum date. You may want to then wrap that query in parentheses as an inline view and query it as an intermediate result set.
BTW: Always post a version number, Always read the FAQ and learn how to post properly ... for example using tags, Always include DDL for the table and some sample data so people can try out a solution. We do not always have time to reinvent the wheel.
Similar Messages
-
Oracle Database Express Edition maximum data size
Hi
We just need to know what is the maximum data(in gb) Oracle database express edition 10g can store in it?
Thanks915071 wrote:
Hi
We just need to know what is the maximum data(in gb) Oracle database express edition 10g can store in it?
Thanks4GB -
Query to find the second maximum date in a table
please give me the query to find the second maximum date in a table
You can try with this
SELECT empno
,hiredate
FROM emp a
WHERE 2 = (SELECT COUNT(DISTINCT hiredate)
FROM emp b
WHERE b.hiredate >= a.hiredate
OR
SELECT empno
,hiredate
FROM (SELECT ROWNUM row_num
,empno
,hiredate
FROM emp a
ORDER BY hiredate ASC
WHERE row_num = 2;Regards
Arun -
How can i query oracle database data to xml file with c++?
I want query data to xml file directly in my c++ application .
I know the oracle XSU provide interferce for query data to xml
file directly.
But XSU for oracle8i does not support c++.
I do not know if XSU for oracle9i support c++.
can you tell me?
If i do not use XSU to finish my applicayion.
what interface that oracle provide can help me do my work?
thank you !BTW why do you want to migrate oracle database data to db2 database? Any specific project requirement like Parallel run with Oracle database (e.g data replication)? Or any other issues - Cost? Manageability? Availability? Business requirements?
Do you need to do a day-to-day data transfer or it is for permanent migration? -
Which oracle data type store Maximum data?
Hi All
could any one suggest me that i store maximum data in oracle data type for that which data type i have to use?
i m working on Oracle 10g
ThanksRefer
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i54330
and choose the data type that you need to (except for LONG - it has too many limitations and is only provided for backward compatibility). -
ADF View Object query to use Oracle LONG data type
Hi,
I'm using a view object that uses Oracle LONG data type.The following exception is thrown
*"java.sql.SQLException: Stream has already been closed"* and it is not fetching the correct data.
I have searched in many forums,they suggested to use LOB instead of LONG as LONG is deprecated. But in my case I can't avoid using LONG as some of my legacy applications using the same DB.
Please suggest me a way
Thanks in Advance
FelixThanks for your reply Arun,
I have solved this problem using the solution suggested by this blog [AskTom-Link|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:839298816582]
In the above blog link,they have suggested to convert Long to Varchar by functions and asked to use this function in the column.
Thank you all guys who have seen this post.
Regards,
Felix -
Find the Next available date which is not necessarily the Maximum Date
Morning folks!
I am trying to find the next scheduled appointment date (Including any day after today) for a patient which may not be the maximum date for that person. I am trying to do this in Oracle Forms. My Query is working in SQL*Plus but is not working in Forms.
FUNCTION get_next_sched_date(P_PATIENT_ID in varchar2) RETURN DATE IS
v_next_scheduled_date patient_visit.target_date%TYPE;
BEGIN
select next_target_date into v_next_scheduled_date
from ( select v.*, max(target_date) over (partition by patient_id) max_target_date,
lead(target_date) over (partition by patient_id order by target_date) next_target_date
from patient_visit v)
where patient_id = P_PATIENT_ID
and next_target_date >= SYSDATE
and max_target_date > next_target_date;
return( v_next_scheduled_date );
EXCEPTION
when NO_DATA_FOUND then
return(NULL);
When I compile this in Oracle Forms, it gives me an Error.Encountered the symbol "(" when expecting one of the following: ,from.
I also noticed that Oracle Forms is not liking keywords such as LAG and LEAD. I am working on Oracle Forms 9i.
Any idea what I am doing wrong here? Thanks for listening to my Monday harping. :-)
Forms [32 Bit] Version 9.0.4.0.19 (Production)
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit ProductionEdited by: Roxyrollers on Aug 27, 2012 8:43 AM
Edited by: Roxyrollers on Aug 27, 2012 8:46 AMThanks.
For now, I have another simpler solution. I was just curious if the first way would have worked.
select MIN(target_date) into v_next_scheduled_date from patient_visit v1
where patient_id = P_PATIENT_ID
and target_date >= SYSDATE
and target_date <= (select MAX(target_date) from patient_visit v2
where v2.patient_id = v1.patient_id);Edited by: Roxyrollers on Aug 27, 2012 9:16 AM -
Governor limit exceeded in cube generation (Maximum data records exceeded.)
There are similar posts which didn't help in my situation.
I had the error: Governor limit exceeded in cube generation (Maximum data records exceeded.). The query returns about *64000* rows.
I've changed the instance config and exagerated it, and then also the register, but I still get the error:Governor limit exceeded in cube generation (Maximum data records exceeded.)
instanceconfig:
<?xml version="1.0"?>
<WebConfig>
<ServerInstance>
<CredentialStore>
<CredentialStorage type="file" path="C:\OracleBIData\web\config\credentialstore.xml"/>
</CredentialStore>
<CubeMaxRecords>5000000</CubeMaxRecords>
<CubeMaxPopulatedCells>10000000</CubeMaxPopulatedCells>
<ResultRowLimit>5000000</ResultRowLimit>
<PivotView>
<MaxVisibleRows>5000000</MaxVisibleRows>
<MaxVisibleColumns>1024</MaxVisibleColumns>
<MaxVisiblePages>1024</MaxVisiblePages>
<MaxVisibleSections>1024</MaxVisibleSections>
</PivotView>
</ServerInstance>
</WebConfig>
Also added
*<CubeMaxRecords>5000000</CubeMaxRecords>*
* <CubeMaxPopulatedCells>10000000</CubeMaxPopulatedCells>*
to the registry.
But still got the error:(
Thanks for your help
Edited by: user635025 on Jul 24, 2009 4:34 AMI suggest disabling the cache. Setting the max rows to a very high number and disabling the cache is the way to go when you are querying an Oracle database :)
( for those who haven't allready did the the thing )
In NQSConfig.INI
# Query Result Cache Section
[ CACHE ]
ENABLE = NO; -
How to select maximum date in report
i have tried to select maximum date in my report by this way:
select max(date) from a
but the result came out same as "select date from a"
there is no different whether i put a max or not. is anyone there can help me on this please....
Thank you....Hi Sharon,
Since you cannot execute this query from SQL, I assume that the DB does not support the function MAX(expr). Am not sure which DB versions support this function, probably the Database forum will be a better place to ask that.
As a workaround, what you could try is to use this statement
select hire_date from employees order by hire_date desc
and in the report data model, you make a summary column and choose Function > First, Source > Hire_Date, and Reset At > Report.
Hope that helps.
Navneet. -
What is the role of Lns process in oracle 10g data guard
Hi ,
plz help me out to find out the actual working of lns process in oracle 10g data guard
when i use SYNC redo transport
the output of v$managed_stanbdy is like that ..
PROCESS PID STATUS CLIENT_PROCESS GR# SEQ#
ARCH 9258 CLOSING ARCH 2 498
ARCH 9260 CLOSING ARCH 1 499
ARCH 9262 CLOSING ARCH 2 496
ARCH 9264 CLOSING ARCH 1 497
LGWR 9206 CLOSING LGWR 2 482
its not display any info about lns,thats means lns is not working in SYNC redo transport mode ?
but if i changed it to ASYNC then the out put of v$managed_stanbdy is like this ..
PS PID STS CPS GR# SEQ#
ARCH 9258 CLOSING ARCH 1 509
ARCH 9260 CLOSING ARCH 2 510
ARCH 9262 CLOSING ARCH 1 505
ARCH 9264 CLOSING ARCH 2 508
LGWR 9206 CLOSING LGWR 1 503
LNS 10528 CLOSING LNS 2 510
Now it display all the info about lns process...
i read in oracle documentation that lns process send redo data from primary,( through network service ) to RFS on standby side.
but first output means that lns is not working,if not then which process send redo from primary to RFS on standby ?
i also read in some blog that lgwr use some extra buffer size from primary db SGA ,to write redo in that buffer ,ans lns read redo from that buffer and send it to RFS on stanby side,
i m totally confused ..can u plz help me with correct logic behind this .
thanx in advance.Hello,
On the primary database when you run the v$managed_standby, it shows up the LNS process as this process sends redo info to the standby database and on the standby database the RFS process receives the redo information.
So on the primary database when you query the v$managed_standby, it shows up LNS and on the standby database when you query the v$managed_standby it shows up RFS. Please let us know where you are running the query.
Refer this http://datadisk.co.uk/html_docs/oracle_dg/architecture.htm
969752
Handle: 969752
Status Level: Newbie
Registered: Nov 6, 2012
Total Posts: 9
Total Questions: 2 (2 unresolved)
Name Hemendra Singh
Location NoidaPlease consider closing your questions by providing appropriate points and marking it as answered. Please keep the forum clean ! -
Maximum Data file size in 10g,11g
DB Versions:10g, 11g
OS & versions: Aix 6.1, Sun OS 5.9, Solaris 10
This is what Oracle 11g Documentation
http://download.oracle.com/docs/cd/B28359_01/server.111/b28320/limits002.htm
says about the Maximum Data file size
Operating system dependent. Limited by maximum operating system file size;typically 2^22 or 4 MB blocksI don't understand what this 2^22 thing is.
In our AIX machine and ulimit command show
$ ulimit -a
time(seconds) unlimited
file(blocks) unlimited <-------------------------------------------
data(kbytes) unlimited
stack(kbytes) 4194304
memory(kbytes) unlimited
coredump(blocks) unlimited
nofiles(descriptors) unlimited
threads(per process) unlimited
processes(per user) unlimitedSo, this means, In AIX that both the OS and Oracle can create a data file of any Size. Right?
What about 10g, 11g DBs running on Sun OS 5.9 and Solaris 10 ? Is there any Limit on the data file size?How do i determine maximum number of blocks for an OS?df -g would give you the block size. OS blocksize is 512 bytes on AIX.
Lets say the db_block_size is 8k. What would the maximum file size for data file in Small File tablespace and Big File tablespace be?Smallfile (traditional) Tablespaces - A smallfile tablespace is a traditional Oracle tablespace, which can contain 1022 datafiles or tempfiles, each of which can contain up to approximately 4 million (222) blocks. - 32G
A bigfile tablespace contains only one datafile or tempfile, which can contain up to approximately 4 billion ( 232 ) blocks. The maximum size of the single datafile or tempfile is 128 terabytes (TB) for a tablespace with 32K blocks and 32TB for a tablespace with 8K blocks.
HTH
-Anantha -
Need a maximum date value using group by
Create table student (dept number(10), dep_name varchar2(10),join_date date,years_attended number(10),end_date date);
insert into student values (1,'I',to_date('3/7/1917','MM/DD/YYYY'),4,to_date('8/26/1987','MM/DD/YYYY'));
insert into student values (1,'I',to_date('1/1/1900','MM/DD/YYYY'),4,to_date('8/26/1932','MM/DD/YYYY'));
insert into student values (1,'D',to_date('1/1/1920','MM/DD/YYYY'),5,to_date('8/26/1994','MM/DD/YYYY'));
insert into student values (1,'C',to_date('1/1/1920','MM/DD/YYYY'),6,to_date('8/26/1945','MM/DD/YYYY'));
insert into student values (2,'I',to_date('7/1/1900','MM/DD/YYYY'),3,to_date('8/26/1932','MM/DD/YYYY'));
insert into student values (2,'I',to_date('8/16/1916','MM/DD/YYYY'),9,to_date('8/26/1923','MM/DD/YYYY'));
insert into student values (2,'D',to_date('8/16/1916','MM/DD/YYYY'),10,to_date('8/26/1987','MM/DD/YYYY'));
insert into student values (3,'I',to_date('3/7/1917','MM/DD/YYYY'),4,to_date('8/26/1987','MM/DD/YYYY'));
insert into student values (3,'D',to_date('7/28/1920','MM/DD/YYYY'),6,to_date('8/26/1945','MM/DD/YYYY'));
insert into student values (3,'I',to_date('7/28/1920','MM/DD/YYYY'),8,to_date('8/26/1965','MM/DD/YYYY'));
insert into student values (4,'I',to_date('12/31/1924','MM/DD/YYYY'),2,to_date('8/26/1998','MM/DD/YYYY'));
insert into student values (4,'I',to_date('6/10/1929','MM/DD/YYYY'),1,to_date('8/26/1943','MM/DD/YYYY'));
insert into student values (4,'C',to_date('1/17/1927','MM/DD/YYYY'),4,to_date('8/26/1955','MM/DD/YYYY'));
insert into student values (4,'C',to_date('6/10/1929','MM/DD/YYYY'),30,to_date('8/26/1967','MM/DD/YYYY'));
insert into student values (5,'D',to_date('2/10/1931','MM/DD/YYYY'),2,to_date('8/26/1943','MM/DD/YYYY'));
insert into student values (5,'I',to_date('2/10/1931','MM/DD/YYYY'),24,to_date('8/26/1962','MM/DD/YYYY'));
commit;I need a maximum date value join_date for each department. If max(join_date) has two records for each dept then max(end_date) should be considered. I have used a below select query
select * from student where join_date in (select
max(join_date) from student group by dept);which gives me the following result
1 D 1/1/1920 5 8/26/1994
1 C 1/1/1920 6 8/26/1945
2 I 8/16/1916 9 8/26/1923
2 D 8/16/1916 10 8/26/1987
3 D 7/28/1920 6 8/26/1945
3 I 7/28/1920 8 8/26/1965
4 I 6/10/1929 1 8/26/1943
4 C 6/10/1929 30 8/26/1967
5 D 2/10/1931 2 8/26/1943
5 I 2/10/1931 24 8/26/1962But I am looking for the result which gives me only one maximum value for each dept column. First it should look for maximum value of join_date, if two records has same join_date then max(end_date) should be considered. The result should be sumthing like this
1 D 1/1/1920 5 8/26/1994
2 D 8/16/1916 10 8/26/1987
3 I 7/28/1920 8 8/26/1965
4 C 6/10/1929 30 8/26/1967
5 I 2/10/1931 24 8/26/1962Can you please tell me how to rewrite the select query to get the above results.
Edited by: user11872870 on Aug 2, 2011 5:29 PM
Edited by: user11872870 on Aug 2, 2011 5:36 PMHi,
That's called a Top-N Query , and here's one way to do it:
WITH got_r_num AS
SELECT student.*
, ROW_NUMBER () OVER ( PARTITION BY dept
ORDER BY join_date DESC
, end_date DESC
) AS r_num
FROM student
SELECT dept, dep_name, join_date, years_attended, end_date
FROM got_r_num
WHERE r_num = 1
ORDER BY dept
;Another way is similar to what you originally posted:
SELECT *
FROM student
WHERE (dept, join_date, end_date)
IN (
SELECT dept
, MAX (join_date)
, MAX (end_date) KEEP (DENSE_RANK LAST ORDER BY join_date)
FROM student
GROUP BY dept
);I suspect the first way (using ROW_NUMBER) will be faster.
Also, the ROW_NUMBER approach is guaranteed to return only 1 row per dept. Using the GROUP BY approach,if there is a tie on join_date and end_date, then it will return all contenders in that dept. Using ROW_NUMBER, it's easy to add as many tie-breaking expressions as you want, and, if there is still a tie, it will arbirarily pick one of the rows involved in the tie as #1.
Thanks for posting the CREATE TABLE and INSERT statments! That's very helpful.
Edited by: Frank Kulash on Aug 2, 2011 9:00 PM
Added GROUP BY alternative -
Search on Maximum Date Formula Field
Hello All,
I am trying to create a report that will return a PART table linked with an outer join to an ORDERDTL table.
What I would like to do is to return only the Maximum (or last) order date for each part and then have a parameter field that will give me a cutoff date for the last ordered.
For example: Part ABC was ordered on 1/1/08 and 1/1/07. Part XYZ was ordered on 1/1/07 and 1/1/06. When I enter a cutoff date of 2/1/07 it should return part XYZ but NOT part ABC because ABC was ordered after the cutoff date.
I can see the parameter being "only return the parts with a maximumdate NOT > parameterdate". I am having trouble getting the maximum date to be available for query.
How do I run a date parameter field against a Formula field with a maximum date?
Any other pointers?
Thanks,
Rossyou need to create a formula MAXIMUM(DATE) i would have it subtotal on a group, i guess your part #.
then in the selection criteria, in the group selection you can use that or use a conditional surpression based upon the parameter -
ORACLE 8I EXPORT의 QUERY OPTION 기능
제품 : ORACLE SERVER
작성날짜 : 2000-09-19
Oracle 8i EXPORT의 Query Option 기능
====================================
Oracle 8i에서는 export 작업 수행 시 Query Option을 이용하여 테이블의
부분적인 추출이 가능하다.
SQL> select empno, ename, job, sal from emp order by job;
EMPNO ENAME JOB SAL
7788 SCOTT ANALYST 3000
7902 FORD ANALYST 3000
9999 홍길동 ANALYST 2000
7369 SMITH CLERK 800
7876 ADAMS CLERK 1100
7934 MILLER CLERK 1300
7900 JAMES CLERK 950
7566 JONES MANAGER 2975
7782 CLARK MANAGER 2450
7698 BLAKE MANAGER 2850
7839 KING PRESIDENT 5000
7499 ALLEN SALESMAN 1600
7654 MARTIN SALESMAN 1250
7844 TURNER SALESMAN 1500
7521 WARD SALESMAN 1250
위와 같이 구성된 EMP 테이블에서 만일 'MANAGER'로 JOB을 가진 사원중 SAL
컬럼이 2500이상인 레코드를 export하고 싶다면, 다음과 같이 수행하면 된다.
% exp scott/tiger tables=emp query=\"where job=\'MANAGER\' and sal\>=2500\"
Export: Release 8.1.5.0.1 - Production on Tue Sep 19 16:14:15 2000
About to export specified tables via Conventional Path ...
. . exporting table EMP 2 rows
exported
Export terminated successfully without warnings.
한글 컬럼에 대해서도 동일한 where 조건에 지정이 가능하다.
% exp scott/tiger tables=emp query=\"where ename like \'홍%\'\"
V8.1.5 버젼에서 제공되는 Query 옵션의 특징:
1. 테이블 레벨의 export 명령어에서만 가능하다.
2. Direct 옵션과 함께 사용될 수 없다.
3. Nested 테이블을 갖는 테이블에는 적용할 수 없다.
4. Partition 테이블에 대한 export에도 적용가능하다.
5. Import 명령에는 적용되지 않는다.Thanks Guys,
I am still a bit lost though...
It may be simply a matter of me finding Oracle 8i so I can do what I need to do.
Where can I get Orcale 8i from? Does anybody have it? The oracle site only has a version back to 9.2 I queried with a employee from Oracle University here in Australia, and he suggested asking in the forums.
Just so you know what I'm trying to do:
Data Server:
Running Aix with Oracle 7.14... actually could be 7.41 - I'll check today.
This system will not be upgraded to any later version of Orcale, because systems are in place, and core systems at our other sites have to be the same. (my project is a local one)
Web Server:
Running XP profession with IIS and using ASP (active server pages)
Currently running Oracle 10g, and ASP code connects to the local database on this machine via an ODBC connection.
At the moment, I have scripts on the Aix server that dumps data from Oracle 7.x into a .csv file.
Then, I have scripts that copy those csv files to the XP server, and they are imported to the local Oracle 10g database.
To display this data on the website, I use ASP via the odbc connection to query the local database on the XP server.
As said in my previous post, there must be an easier way to do this.
I need a local database on the XP server too, and am thinking the best way is to downgrade to 8i.
Can anybody tell me where I can get 8i to try this out? I have been trying to reasearch this for a while now without luck. Any help would be appreciated, and thanks for those who have replied so far.
-Tom -
Sql loader maximum data file size..?
Hi - I wrote sql loader script runs through shell script which will import data into table from CSV file. CSV file size is around 700MB. I am using Oracle 10g with Sun Solaris 5 environment.
My question is, is there any maximum data file size. The following code from my shell script.
SQLLDR=
DB_USER=
DB_PASS=
DB_SID=
controlFile=
dataFile=
logFileName=
badFile=
${SQLLDR} userid=$DB_USER"/"$DB_PASS"@"$DB_SID \
control=$controlFile \
data=$dataFile \
log=$logFileName \
bad=$badFile \
direct=true \
silent=all \
errors=5000Here is my control file code
LOAD DATA
APPEND
INTO TABLE KEY_HISTORY_TBL
WHEN OLD_KEY <> ''
AND NEW_KEY <> ''
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
OLD_KEY "LTRIM(RTRIM(:OLD_KEY))",
NEW_KEY "LTRIM(RTRIM(:NEW_KEY))",
SYS_DATE "SYSTIMESTAMP",
STATUS CONSTANT 'C'
)Thanks,
-Soma
Edited by: user4587490 on Jun 15, 2011 10:17 AM
Edited by: user4587490 on Jun 15, 2011 11:16 AMHello Soma.
How many records exist in your 700 MB CSV file? How many do you expect to process in 10 minutes? You may want to consider performing a set of simple unit tests with 1) 1 record, 2) 1,000 records, 3) 100 MB filesize, etc. to #1 validate that your shell script and control file syntax function as expected (including the writing of log files, etc.), and #2 gauge how long the processing will take for the full file.
Hope this helps,
Luke
Please mark the answer as helpful or answered if it is so. If not, provide additional details.
Always try to provide actual or sample statements and the full text of errors along with error code to help the forum members help you better.
Maybe you are looking for
-
I'M (not) SEEING RED! Color Sync issues w/ Pixma 4000
For some reason the magenta is really off on my printer (canon pixma 4000). Regardless if I print something on Photoshop, iPhoto 5, or Google Maps (Double True), the red hue is a faded hue, almost orange. All my inks are full and have been installed
-
Hard Drive Crash! Please help
I was surfing the internet when my itunes froze up, and then safari froze up. So I just rebooted and I got the flashing folder icon with the ? in the middle of it. I popped in the install CD and help down "c". I went to disk utility where the hard dr
-
Updating Forefront hotfixes and virus definitions
Experts, We have Microsoft forefront and our security engineer informed that we use SCCM to update virus definitions and WSUS to update application version. We want to use Intune for this machines, which cannot co exist with SCCM agent on machines.
-
Dream build for Premiere Pro CC 2014 feature film editing...
How does something like this feel? Case Something "silent" Power-Supply 850w quiet Processor Intel i7 Haswell Extreme CPU Clockspeed 4.4GHz Cores 5960X = 6 (16 threads), 5930k = 6 (12 threads), 5820k = 4 (12 threads) Cooler 280mm Memory /
-
My imovie keeps crashing everytime I try to export, what can I do please help
Process: iMovie [447] Path: /Applications/iMovie.app/Contents/MacOS/iMovie Identifier: com.apple.iMovie8 Version: 8.0.6 (821) Build Info: iMovieApp-8210000~16 Code Type: X86 (Native) Parent Process: launchd