473,597 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_dateti me)

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 2416

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

Similar topics

11
3301
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 machine executes about 6 seconds: <? $db_conn = ocilogon("my_username", "my_password", "my_database"); $loop_count = 1000;
3
5216
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 luck yet. Here is a short description of what I did so far: 1. I installed the jdk118_v3-glibc-2.1.3.tar in the /usr/local/ dir and made a symbolic link from /usr/local/java to this 2. I installed all the necessary groups and users (oracle,...
3
3967
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 odbc driver. Records should be returned but nothing.
1
5357
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), acgr.group_code, bank.local_acc_no, bank.short_name,
3
2490
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 web module component to update the relevant grandparent record of STOCK, and when UPDATED, to remember the previous level and adjust accordingly. I'm sure that this can probably be done in PL/SQL, but don't have a clue how - all books and...
4
16822
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. I had her send me her tnsnames.ora from her PC. The entry I wanted was as follows (some letters replaced with xxx for security reasons):
1
8552
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 when saving this procedure. (Not when compiling; it has no errors) Server: Msg 7405, Level 16, State 1, Line 1 Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query...
2
6098
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, but I've read a pass-through query can pass the passwords automatically. The directions seem straightforward, but I can't get one to work. The select query from the ODBC linked table looks like: SELECT OSCAR_TBLSALESMAN.SALESMAN,...
0
444
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 table #temp1 ( groupcode char(10), loc_acc_no int, gin int,
0
8267
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8024
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5844
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5423
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3880
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3921
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2394
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1229
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.