473,699 Members | 2,087 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,
from #temp1 t1,
#temp2 t2
where t1.loc_acc_no = t2.loc_acc_no
and t1.gin = t2.gin
group by
having t2.N_datetime = max(t2.N_dateti me)

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
be much appreciated.

Jul 19 '05 #1
0 2429

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

Similar topics

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;
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,...
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.
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,
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...
by: Tig | last post by:
Hi all. I have a need to connect to an Oracle 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):
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...
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,...
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,
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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...
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...
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.