List:General Discussion« Previous MessageNext Message »
From:Harry Brueckner Date:March 12 1999 3:54pm
Subject:SQL question
View as plain text  
Hello,

I have problems getting the proper SQL statement for the following problem.

I have this table:

| Shop | Article | Amount |
| A    |       1 |      3 |
| B    |       1 |     17 |
| C    |       1 |      9 |
| D    |       1 |     25 |
| A    |       2 |     14 |
| B    |       2 |     29 |
| G    |       2 |      1 |
| D    |       3 |    212 |
| E    |       3 |     17 |
| F    |       3 |     35 |

Now I want to select each article just once, where it has the amount is the
maximum.
The result for my example should be:

| Shop | Article | Amount |
| D    |       1 |     25 |
| B    |       2 |     29 |
| D    |       3 |    212 |

How can I select just these rows ?

Harry


PS: Does anyone know a good SQL book which helps to get those little harder
    SQL questions answered. Something like a "SQL Cookbook" or something ?


 ===================================================================
  PGP fingerprint: B9 EE 83 0C 1F 48 54 50  9F A7 7A 00 6C 94 36 02
  PGP public key available by fingering harry@stripped

Thread
SQL questionHarry Brueckner12 Mar
  • Re: SQL questionMartin Ramsch13 Mar
  • Re: SQL questionChristian Mack13 Mar
  • Re: Mysql update logs trouble.sinisa20 Apr
  • Re: Innobase released in MySQL-3.23.34a source distribution: transactions and row level locking now in MySQLJean-Luc Fontaine12 Mar