Hi,
I have the following table
1001 2 3
1001 3 5
1001 5 7
1002 5 4
1002 6 2
I need to get a result
1001 2 3
1002 6 2
How is it possible ? 3 10876
question's a little vague, but assuming you are trying to get records for
the minimum values of the first and third column, for all rows in a table,
you could try a subquery like
select *
from x
where (col1, col3) in (
select col1, min(col3)
from x
group by col1
)
but don't try this until you understand why it works ;-)
-- mcs
"Ravindra Harve" <rh****@hotmail.com> wrote in message
news:83**************************@posting.google.c om...
| Hi,
|
| I have the following table
|
| 1001 2 3
| 1001 3 5
| 1001 5 7
| 1002 5 4
| 1002 6 2
|
| I need to get a result
|
| 1001 2 3
| 1002 6 2
|
| How is it possible ?
Use this one , the same but easier
select *
from (
select col1, min(col3)
from x
group by col1
)
"Mark C. Stock" <mcstockX@Xenquery .com> wrote in message
news:D_********************@comcast.com... question's a little vague, but assuming you are trying to get records for the minimum values of the first and third column, for all rows in a table, you could try a subquery like
select * from x where (col1, col3) in ( select col1, min(col3) from x group by col1 )
but don't try this until you understand why it works ;-)
-- mcs
"Ravindra Harve" <rh****@hotmail.com> wrote in message news:83**************************@posting.google.c om... | Hi, | | I have the following table | | 1001 2 3 | 1001 3 5 | 1001 5 7 | 1002 5 4 | 1002 6 2 | | I need to get a result | | 1001 2 3 | 1002 6 2 | | How is it possible ?
Julia,
Not the same by any means.
Your select * does absolutely nothing -- the subquery results are simply
passed thru unchanged
Your subquery contains only two columns -- the assumption is that all
columns should be displayed
Try them both on the EMP table with the empno, deptno, and sal in the
resultset and dept and sal in the subquery ("Write a report that lists the
lowest paid employees in each department")
-- mcs
"Julia Sats" <ju********@sympatico.ca> wrote in message
news:iK*********************@news20.bellglobal.com ...
| Use this one , the same but easier
| select *
| from (
| select col1, min(col3)
| from x
| group by col1
| )
|
| "Mark C. Stock" <mcstockX@Xenquery .com> wrote in message
| news:D_********************@comcast.com...
| > question's a little vague, but assuming you are trying to get records
for
| > the minimum values of the first and third column, for all rows in a
table,
| > you could try a subquery like
| >
| > select *
| > from x
| > where (col1, col3) in (
| > select col1, min(col3)
| > from x
| > group by col1
| > )
| >
| > but don't try this until you understand why it works ;-)
| >
| > -- mcs
| >
| >
| > "Ravindra Harve" <rh****@hotmail.com> wrote in message
| > news:83**************************@posting.google.c om...
| > | Hi,
| > |
| > | I have the following table
| > |
| > | 1001 2 3
| > | 1001 3 5
| > | 1001 5 7
| > | 1002 5 4
| > | 1002 6 2
| > |
| > | I need to get a result
| > |
| > | 1001 2 3
| > | 1002 6 2
| > |
| > | How is it possible ?
| >
| >
|
| This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: forums_mp |
last post by:
I've got an STL class (see below) with two functions to store and
retrieve data - msg structs.
The "Store" function when called will copy the received message
(depending on which message) into...
|
by: Eugfene |
last post by:
I have the following function in a html file:
function selectEdit(fileID, processCode, processID, fileName,fileDesc)
{
document.forms.recordID.value = fileID;
document.forms.processor.value =...
|
by: Roy Gourgi |
last post by:
Hi,
I am used to working in Visual FoxPro and I would like to be able to create
a database and store and retrieve information from it. What is the simplest
way to do it and what should I be...
|
by: marco.nl |
last post by:
it fails to retrieve newly intruduced data by the user.
i tried this ...
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
UpdateData(FALSE);
and this.....
|
by: jay |
last post by:
I am using the dataset object to add a row to a sql server database in vb.net
code, as follows:
dim drow as DataRow
dim cmdBld as new SqlCommandBuilder(mySqlDataAdapter)
ds.tables(0).NewRow()...
|
by: Frank |
last post by:
Can I do this?
I add a session var in C# and ultimatly want to pass it into a vbscript
client side activeX control. This is what I have so far but get " Object
Required:'name2' " error.
Can...
|
by: kang jia |
last post by:
hi
i am doing mailinglist currently. the code in my first page is like this :
:
<html>
<head>
<link rel="stylesheet" type="text/css" href="gallery.css" />
<script language="JavaScript">
...
|
by: giandeo |
last post by:
Hello Experts.
Is it possible to retrieve the value from a populated pull down menu from a database and then use that value to access the same database to get the related fields.
Example:
...
|
by: Cramer |
last post by:
Using ASP.NET 3.5...
As far as I know, any time we store a value in application or session state,
it is stored as a humble 'object' type rather than it's "real" type.
For example, if we want...
|
by: divya |
last post by:
Hello,
I used the below code to move selected items between two listboxes
Left and Right:-
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %>
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
| |