|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I am having a little problem here with MAX function and would be very nice if anyone could guide me through this.
I have the table called sale1. I have several columns but I dont want to confuse you with all of them. Lets just say I have the following two columns with the two records:: sale_id number SL0001 1 SL0002 2 Now to display the the maximum number we do the following: select max(number) from sale1 Output: 2 How could I display the sale_id next to it? Expected Output: SL0002 2 I tried lots of ways before posting this message. I did subquery as well. select sale_id, number from sale1 where number in (select max(number) from sale1); The server gave me error. I dont know what the error i.......If anyone could give me some instructions it will be very nice. |
|
#2
|
|||
|
|||
|
If all you want is the highest number, just do this:
Code:
SELECT * FROM yourtable ORDER BY number DESC LIMIT 1 |
|
#3
|
|||
|
|||
|
Thank you very much. That is all i wanted and it worked perfectly.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Having problem with MAX function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|