|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Dunno how to write this query
User_ID:
Number: I am needing to get the largest number of out this table... then if there is a tie i'm wanting to select a random User_ID out of the results of the highest number help? :P |
|
#2
|
|||
|
|||
|
SELECT MAX(number) FROM TABLE should get you started.
|
|
#3
|
|||
|
|||
|
Max () function
Just in addition to fidi's posting...
You are required to specific a column name using "AS" for example... SELECT MAX(number) AS a_number FROM TABLE The addition of Quote:
In relation to the random number, you could use the function randrange() to generate a random number between 0 and the max number returned in the above eg SELECT recordset. http://livedocs.macromedia.com/cold...2.htm#wp1110957 For example... <cfoutput query="GetNumber"> <cfset Number = #RandRange(0, a_number)#> </cfoutput> <cfquery name="GetUserID" datasource="YourDatasource"> SELECT User_ID FROM a_table WHERE User_ID = #Variables.Number# </cfquery> I think that that should work...anyone else's comments! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Dunno how to write this query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|