473,785 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 13778
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.c om>
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
1625
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: MenuID TabText SubTabID TabOrderID ------- ----------- ----------- -----------
1
1998
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. I've just added new prices to several drop-downs on our javascript-based ordering page. These new prices must have shipping costs added to them at the bottom of the ordering system in a text box called "Shipping", while the existing prices do not...
2
3211
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 allow someone access to SQL Server using the Guest account over the Internet, and i solved such type of tricky questions before in ucertify. I feel i could have done better. Good luck to all who are preparing to take this exam.
0
1183
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 computers and everywhere it works just fine. Everywhere but two machines... _important_ machines... I see there is no other way to sit by the computers and investigate the issue. To do so I need a debugger - it's enought if it can tell me where an...
25
3410
by: PyPK | last post by:
What possible tricky areas/questions could be asked in Python based Technical Interviews?
8
1885
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 *s1="abcd",*s2=NULL; /* From here you call a function copy which has return type void .
14
2045
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 as coords for SIZE^3 different points in a 3d space: Now, instead of point consider Cubes. They each have 6 sides:
9
1724
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 type="text/javascript">
1
467
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 11:00:00 1 2
0
9645
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
9481
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,...
0
10341
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...
0
10155
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 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...
0
8979
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...
1
7502
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
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
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
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.