Hi Miguel,

As far as I know (I'm no expert), this can't be done in a single MySQL
query. The following link shows how you can do it using a temporary table:

http://www.mysql.com/documentation/mysql/bychapter/manual_Tutorial.html#exam
ple-Maximum-column-group-row

Alternatively, if you are using MySQL in conjunction with a programming
language you could:

SELECT MAX(Version) FROM versions GROUP BY Number;

store result in a variable

SELECT Number, Version,Description FROM versions WHERE Version=<your
variable>

Hope this helps,

Regards,

Chris

> -----Original Message-----
> From: Miguel Alves (SEP) [mailto:[EMAIL PROTECTED]]
> Sent: 27 February 2002 18:21
> To: [EMAIL PROTECTED]
> Subject: SQL
>
>
> Hi,
>
>       I'm using MySQL for the first time and have been trying to
> solve this basic SQL problem for 2 days... I have tried
> everything from using JOINs to local variables, searching in
> www.mysql.com and Paul DuBois MySQL book (Great book!), but
> failed to do this in a single SQL query has I had use to do with
> Microsoft SQL Server.
>
>       The problem is;
>
>       If I have this table (versions):
>
> Number | Version | Description
>      1     |      A     | testing
>      1     |      B     | flying
>
>
> And use this query:
>
> SELECT Number,MAX(Version),Description FROM versions GROUP BY Number;
>
>
> I will get:
>
> Number | Version | Description
>      1     |      B     | testing
>
>
> Instead of:
>
> Number | Version | Description
>      1     |      B     | flying
>
> How can I make a single query that solves this problem ?!?! does
> anyone knows ?
>
> Thanks,
>
> Miguel Lupi Alves
> Methods & Tools Specialist, Helpdesk Methods & Tools
> Customer Solutions
>
> Ericsson Telecomunicações, Lda.
> Division Global Services
> Tel: +351 446 66 58
> Fax: +351 21 446 66 66
> Mobile: +351 91 760 14 24
> mailto:[EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
>



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to