473,714 Members | 2,264 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 2432

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

Similar topics

11
3309
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
5226
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
3979
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
5366
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
2492
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
16844
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
8560
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
6104
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
8808
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9316
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
9077
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,...
0
9021
tracyyun
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...
0
7954
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4465
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...
1
3159
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
2
2524
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2113
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.