473,385 Members | 1,351 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,385 software developers and data experts.

SQL LEAST() function question

103 100+
Hello

Using MySQL 5.0. I'm trying to select a set of data and somehow pick out rows with the smallest number in one of the columns.

Example:
Expand|Select|Wrap|Line Numbers
  1. SELECT first_name, LEAST(height) 
  2. FROM people
  3. INNER JOIN heights ON name_id_pk=name_id_fk
  4.  
I know LEAST() shouldn't be used like this but is there a way to do this?

The data in the table would be something like
people.first_name: heights.height:
Henry 1.8
Henry 1.6
Henry 1.9
Arthur 1.5
John 1.8
John 1.7

The select query would pick out Henry (1.6), Arthur (1.5), John (1.7) as they are the smallest of each person with the same name.

Hopefully that makes sense. Any help is much appreciated.

Henry
Jul 30 '07 #1
1 2452
r035198x
13,262 8TB
Hello

Using MySQL 5.0. I'm trying to select a set of data and somehow pick out rows with the smallest number in one of the columns.

Example:
Expand|Select|Wrap|Line Numbers
  1. SELECT first_name, LEAST(height) 
  2. FROM people
  3. INNER JOIN heights ON name_id_pk=name_id_fk
  4.  
I know LEAST() shouldn't be used like this but is there a way to do this?

The data in the table would be something like
people.first_name: heights.height:
Henry 1.8
Henry 1.6
Henry 1.9
Arthur 1.5
John 1.8
John 1.7

The select query would pick out Henry (1.6), Arthur (1.5), John (1.7) as they are the smallest of each person with the same name.

Hopefully that makes sense. Any help is much appreciated.

Henry
Group by name is the thing that comes into my mind here. Have a look at it and see what you can come up with.
Jul 30 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mini Mouse | last post by:
Hiya folks, I'm getting the following error(s) below and I'm at a bit of a loss as to how to correct it. When I give it a parameter it then complains it needs two parameters and the second one...
20
by: GS | last post by:
The stdint.h header definition mentions five integer categories, 1) exact width, eg., int32_t 2) at least as wide as, eg., int_least32_t 3) as fast as possible but at least as wide as, eg.,...
52
by: onsbomma | last post by:
I want to set and reset the least significant bit of a address (where a pointers points to). I tried this, but it is not correct: #define BIT 0x1 void foo(){ void *p; *p = *p & ~BIT
6
by: Just Me | last post by:
My Task List contains the following: At least one reference is missing the 'Name' attribute. Any suggestion on how toe find which project is missing it? Solution contains 25 projects. ...
2
by: fltcpt | last post by:
After reading the many posts on the newsgroup, I still disagree with the people who claim you will never need a sleep(), or that a sleep() is a bad idea, or that sleep() does not fit in the event...
1
by: DoomedLung | last post by:
Hey, I'm currently developing an online work brief, where the user has to enter details regarding the project into a form. I've come to a section in the form where the user has the option of...
2
by: DoomedLung | last post by:
Hey, I'm currently developing an online work brief, where the user has to enter details regarding the project into a form. I've come to a section in the form where the user has the option of...
2
by: petermichaux | last post by:
Hi, It seems like determining element position in a web page is a difficult task. In the position reporting source code I've looked at there are special fixes for at least some versions of...
1
by: Uwe Kotyczka | last post by:
Hallo, sorry for multiposting, but I am really looking for some hint to solve my problem. And no, I don't use Matlab, but maybe the matlab people have an idea nevertheless. I have to solve a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.