473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Having problems running query in Oracle

I have two tables and want to find the Maximum date for a given GIN.
I have been able to produce the result in Sybase but I am having
problems in Oracle.

Example of my query in Sybase.

create table #temp1 (
groupcode char(10),
loc_acc_no int,
gin int,
amount money,
brancode char(10) )

create table #temp2 (
loc_acc_no int,
gin int,
N_datetime smalldatetime,
notetext char(10) )

insert into #temp1 values("GM",26,3920,100.10,'a')
insert into #temp2 values(26,3920,'14 Oct 2003 03:43','Simple')
insert into #temp2 values(26,3920,'14 Oct 2003 03:42','Repair')
insert into #temp2 values(26,3920,'08 Oct 2003 06:37','Simple')

insert into #temp1 values("GM",26,3921,200.10,'b')
insert into #temp2 values(26,3921,'08 Oct 2003 06:36','Repair')
insert into #temp2 values(26,3921,'08 Oct 2003 06:34','Repair')
insert into #temp2 values(26,3921,'08 Oct 2003 00:17','Simple')

insert into #temp1 values("GM",27,3922,300.10,'c')
insert into #temp2 values(27,3922,'03 Oct 2003 07:05','Simple')
insert into #temp2 values(27,3922,'03 Oct 2003 07:04','Repair')

/******************************************/
My query to produce my result.

select t2.N_datetime,
t1.groupcode,
t1.loc_acc_no,
t1.gin,
t1.amount,
t1.brancode,
t2.notetext
from #temp1 t1,
#temp2 t2
where t1.loc_acc_no = t2.loc_acc_no
and t1.gin = t2.gin
group by
t1.gin
having t2.N_datetime = max(t2.N_datetime)

Results
-------
N_datetime groupcode loc_acc_no gin amount brancode notetext
14/10/2003 03:43:00.000 GM 26 3920 100.10 a Simple
8/10/2003 06:36:00.000 GM 26 3921 200.10 b Repair
3/10/2003 07:05:00.000 GM 27 3922 300.10 c Simple
If anyone can help re-write the above query so it works in Oracle that
would
be much appreciated.

Thanks
George
Jul 19 '05 #1
0 2393

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Markku Uttula | last post by:
I think I'm doing something wrong. I'm able to connect to Oracle just fine, execute queries and all, but I'm having serious problems with the speed :( For example, the following PHP-script on my...
3
by: Jan Bols | last post by:
I've been trying to install Oracle 8.1.7 on a fresh Mandrake 9.1 O.S for days, but I'm still not able to get it running. I've tried several install instructions that I found on the internet but no...
3
by: jhweb | last post by:
I am trying to query a table in oracle from Access 2000 using the following criteria. select * from table1 where DATE_RECEIVED between '1/jan/2003' and '30/jun/2003' I am using the Oracle...
1
by: George | last post by:
Hi, I am trying to write a query in Oracle which I have not done before, and are having some difficulty getting my result. Please check my query and my results. select max(note.datetime),...
3
by: none | last post by:
Hi. I'm implementing a web deployment using 9i. I have a table for STOCK, which has one or more PURCHASES, which have one or more PURCHASE_ITEMS. When a purchase item is INSERTED, I'd like the...
4
by: Tig | last post by:
Hi all. I have a need to connect to an Oracle 7.3.3.5 database. I have a user who successfully connects to it with her Oracle 7.3 client. I have an Oracle 9.2 client installed on my machine....
1
by: A.M. de Jong | last post by:
When I perform a query on a linked Oracle server in the Query analyser I have no prboblem' to perform this query. However, when I create this query in a stored procedure I get a compilation error...
2
by: neptune | last post by:
I currently link a table to an Oracle db. Anytime I open a query based off it, I have to input username & password. Is there a way to do this automatically? I'd prefer to use linked tables,...
0
by: George | last post by:
I have two tables and want to find the Maximum date for a given GIN. I have been able to produce the result in Sybase but I am having problems in Oracle. Example of my query in Sybase. create...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.