ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old March 6th, 2005, 04:52 PM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
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

Reply With Quote
  #2  
Old March 6th, 2005, 07:34 PM
fidi fidi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 4 fidi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 14 sec
Reputation Power: 0
SELECT MAX(number) FROM TABLE should get you started.

Reply With Quote
  #3  
Old March 6th, 2005, 10:58 PM
hoolahawk hoolahawk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Australia
Posts: 57 hoolahawk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 29 m 43 sec
Reputation Power: 4
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:
AS a_number
is as I have said required (change the column name to anything that suits your fancy, say I could have made it my_number or num or anything you want.

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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Dunno how to write this query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway