Re: Need Distinct and Min...
* Lewis Watson I have a table with three fields. In the first field I have a range of numbers 1-20; all repeated more than once. In the third field I have a number ranging from 1 to 20 in each row. I need to choose the lowest amount in the third column for each distinct value in the fist column. Will someone help me out with this query? Maybe I am misinterpreting your question, because this seems like a standard GROUP BY query creating some test data: use test; create table lewis (f1 int,f2 int,f3 int); insert into lewis values (1,0,1); insert into lewis values (1,0,10001); insert into lewis values (2,0,10021); insert into lewis values (2,0,10022); insert into lewis values (3,0,10032); insert into lewis values (3,0,10033); mysql select * from lewis; +--+--+---+ | f1 | f2 | f3| +--+--+---+ |1 |0 | 1 | |1 |0 | 10001 | |2 |0 | 10021 | |2 |0 | 10022 | |3 |0 | 10032 | |3 |0 | 10033 | +--+--+---+ 6 rows in set (0.00 sec) mysql select f1,min(f3) from lewis group by f1; +--+-+ | f1 | min(f3) | +--+-+ |1 | 1 | |2 | 10021 | |3 | 10032 | +--+-+ 3 rows in set (0.09 sec) Is this what you wanted? Some related links: URL: http://www.mysql.com/doc/en/example-Maximum-column-group.html URL: http://www.mysql.com/doc/en/Group_by_functions.html URL: http://www.mysql.com/doc/en/example-Maximum-column-group-row.html -- Roger - 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
re: Need Distinct and Min...
On Monday 17 February 2003 04:20, Lewis Watson wrote: I have a table with three fields. In the first field I have a range of numbers 1-20; all repeated more than once. In the third field I have a number ranging from 1 to 20 in each row. I need to choose the lowest amount in the third column for each distinct value in the fist column. Will someone help me out with this query? Something like: SELECT MIN(third_column) FROM table_name GROUP BY first_column; -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net ___/ www.mysql.com - 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
Need Distinct and Min...
I have a table with three fields. In the first field I have a range of numbers 1-20; all repeated more than once. In the third field I have a number ranging from 1 to 20 in each row. I need to choose the lowest amount in the third column for each distinct value in the fist column. Will someone help me out with this query? Thanks. Lewis mysql, thanks - 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