473,406 Members | 2,633 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,406 software developers and data experts.

tricky SQL question!

JZ
Oracle 9iR2

I have a table:

SQL> select * from test;

A B C
------------------- ---------- ----------
01/01/2004 10:00:00 1 1
01/01/2004 11:00:00 1 2
01/01/2004 11:00:00 2 3
01/01/2004 13:00:00 2 4
01/01/2004 12:00:00 2 5

For every different B value, I want to see the max A value and the
corresponding C value. In the above example, the result shoud be:

A B C
---------------------- ---- ---
01/01/2004 11:00:00 1 2
01/01/2004 13:00:00 2 4
How can I do this in SQL (no PL/SQL or SQL block)?

Thanks a lot!
Jul 19 '05 #1
1 13755
VC
Well, it's rather trivial:

select * from t1 x
where a=(select max(a) from t1 where b=x.b)
VC

----- Original Message -----
From: "JZ" <ib****@yahoo.com>
Newsgroups: comp.databases.oracle
Sent: Thursday, February 05, 2004 5:09 PM
Subject: tricky SQL question!

Oracle 9iR2

I have a table:

SQL> select * from test;

A B C
------------------- ---------- ----------
01/01/2004 10:00:00 1 1
01/01/2004 11:00:00 1 2
01/01/2004 11:00:00 2 3
01/01/2004 13:00:00 2 4
01/01/2004 12:00:00 2 5

For every different B value, I want to see the max A value and the
corresponding C value. In the above example, the result shoud be:

A B C
---------------------- ---- ---
01/01/2004 11:00:00 1 2
01/01/2004 13:00:00 2 4
How can I do this in SQL (no PL/SQL or SQL block)?

Thanks a lot!

Jul 19 '05 #2

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

Similar topics

3
by: Martin | last post by:
Dear Group I wonder whether you can push me in a direction on how to design the following statement. I'm looking for a SELECT with some tricky ORDER BY. The database table looks like this: ...
1
by: Tim | last post by:
Hello, I'm extremely puzzled; I cannot figure out what I'm doing wrong. Here's the situation. I would really appreciate any suggestions. I'm modifying a shopping cart in the following way....
2
by: Kennedy_f | last post by:
Most questions of exam 70-228 have a selection of answers that all seem correct, but in reality, the right answer is the one that best solves the question.There a few trick questions like how to...
0
by: Piotr Szukalski | last post by:
Hi! I have a quite tricky question about .NET debugger: do I need to install the whole SDK to make SDK CLR debugger working? The situation is as follows: I have an application deployed to 130...
25
by: PyPK | last post by:
What possible tricky areas/questions could be asked in Python based Technical Interviews?
8
by: pras.vaidya | last post by:
Hi , below given question was asked to me during an interview and i figured it out little tricky . It would be a great help if anyone could solve it. Code : - main() { char...
14
by: felixnielsen | last post by:
Consider this 3d vector: const SIZE = 'some_size'; std::vector<std::vector<std::vector<char> > >GRID(SIZE, std::vector<std::vector<char> >(SIZE, std::vector<char>(SIZE))); It can be viewed...
9
by: howachen | last post by:
Hi, I have one very simple tricky question which is quite interesting, I would like to share with all of you here... //======================================= <script...
1
by: JZ | last post by:
Oracle 9iR2 I have a table: SQLselect * from test; A B C ------------------- ---------- ---------- 01/01/2004 10:00:00 1 1 01/01/2004...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
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,...
0
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...

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.