tomas.hortlax Posted March 5, 2010 Share Posted March 5, 2010 Hi Please forgive me. I'm new in this. This problem I have may be very easy to resolve.But I can't. And forgive my bad english. I have a database with many values. My problem is that I just want to display the max value of two different values. (of many more)Like this exempel. I have three column name. A, B and CA is only textA B CAB 1 1CD 1 2EF 2 1GH 2 2IJ 2 3KL 3 1MN 1 3I want to display value A of every B value with max value of C.Like this...MN (B=1 and max C=3)IJ (B=2 and max C=3)KL (B=3 and max C=1)We begin with that problem. Later I want to calculate some other values.../ThanksTomas Link to comment Share on other sites More sharing options...
justsomeguy Posted March 5, 2010 Share Posted March 5, 2010 I'm not sure if this solves your problem, but you can order by the columns and just select the top few rows. e.g.:SELECT A FROM table ORDER BY C DESC, B DESC LIMIT 3 Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 6, 2010 Author Share Posted March 6, 2010 I'm not sure if this solves your problem, but you can order by the columns and just select the top few rows. e.g.:SELECT A FROM table ORDER BY C DESC, B DESC LIMIT 3There is a problem. ( I think)I dont know what the user will do with the databas.There is no limit in the values. But they will allways increase with 1.Thers is a serie like thisB=1 and C will increase with one, and I dont know when it stopBut B can have changed many times (always increased with 1) before C change when B=1.I dont know if you understand. My english is not so good./Tomas Link to comment Share on other sites More sharing options...
justsomeguy Posted March 8, 2010 Share Posted March 8, 2010 I'm not sure I understand, run the code I wrote and see if that works for what you're trying to do. Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 9, 2010 Author Share Posted March 9, 2010 I'm not sure I understand, run the code I wrote and see if that works for what you're trying to do.I did like this.Selected the max value from BMade a loop from 1 to BDisplayed B and max value on C for each B value (1,2,3 etc)Worked for me Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.