I have 30 numbers. I need to select randomly 10 out of the given 30. A number must not repeat ( eg. i can't have number 10 twice ). How can i do this??
I will attach a zipped file with data in it. I want to pull distinct phone numbers from column B and column D (as some of the numbers will be the same). then rank by asc order based on TotalCashPrice. If they are the same, I want to compare the TotalCashPrice to TotalCashPrice2. Is that possible?
i have a DB with table named Products. pCategory lists several names of teams of varing leagues (NBA, NFL, MLB, etc...) I want a table to display only the NBA teams. I have a field named pGroup which has NBA, MLB, etc... for each team. How can I display all fields where pGroup="NBA." I thought the code would work below, but it didn't.
<%sql_getProducts = "SELECT DISTINCT pCategory WHERE pGroup="NBA" FROM products"
sql = "SELECT DISTINCT LName FROM myTable ORDER BY userID"
But this produces an error saying you cannot use DISTINCT and ORDER BY in the same statement. What is the best way I can achieve a sorted list of unique values?
I m trying to use select statement in order to select a distinct word like 'c', but in the database i only want to select c when it occurs on its own not when it appears in another word.
eg i need to select the alphabet 'c' in 'the cat category is c' but not the 'c' in 'cat' or 'category'. I have used the code below but this seem to count all 'c'
select set rsTypes2 = con.execute("SELECT COUNT(two) AS total FROM march where two like '%c%'")
please bare with me here: <% dim VAR(2) VAR(1)="nba" VAR(2)="mlb"
sql_getVAR = "SELECT DISTINCT pcity FROM VAR" Set getVAR = Conn.Execute(sql_getVAR) %>
I want several table according to the sport (nba,mlb, nfl etc...) I thought if i put the above code on an asp page (page02.asp) and then specified VAR on page01.asp with the link for NBA being /teams_02.asp?VAR=1 it would display the fields from the "nba" table. Of course it did not saying the error was that VAR was not defined. Can someone tell me what I am doin wrong or if you understand it, explain a better way to me.
I have a problem creating random numbers. I basically have this
Randomize() iRandom = Int(10 * Rnd + 1)
If I do not wait a few sec before hitting the page again it will create the same random number as generated a few seconds before.Any idea why it is like that? Another way to reprocess the "bug" is to just fit F5 few times in a row and you end up with the same number being generated. Its annoying and I need some help to "fix" it!
I am developing a online test application(multiple choice ques) So for that i need to shuffel the questions randomly. eg there will be 60 Questions in total. If say 50 users are connected to it, all will be having same 60 questions but its order should be different.
i am using below code to randomly generate questions numbers but the problem with this code is it is repeating the number.I want to generate non repeatable numbers. Can anyone help me out to do it.
Dim my_num,max,min Dim i i = 0 max=60 min=1 For i = 1 to 60 Randomize my_num=int((max-min+1)*rnd+min) Response.Write my_num & "<br>" Next
I am trying to create a random value between 10 and 1,000,000. I am using the following code but it is creating numbers between 10,000 and 999,999. How can I fix it.
I am using DreamweaverMx to create a football website that stores players to a databse and when they join a game there is a function to randomize a number for each player and store it on a second databse and from the database using sql to link my databases together so that a players details are posted on a page of my website.
I want to generate random selection of user, according to their points respectively, so the more points he has, the more likely he will be selected:
user1 in 10% cases user2 in 10% cases user3 in 10% cases user4 in 20% cases user5 in 50% cases
this percentage is respective to their points; I put some rounded numbers in the example - so total points of 1000 equals 100% - but they can have any amount of points: 1, 200, 3672 etc.
I’m having problems on how to randomiz numbers and delete the ones that have been displayed.
My first step is to take some numbers:
21, 32, 35, 4, 15 and randomize theese so the ouput may look something like this: 35, 21, 15, 32, 4
My second step is to display the first number (35), then when a user clicks on a link I want the second of my random number (21) to be displayed and I also want to delete the first number (35) that has been displayed. And this routine (display number, delete previous number) should continoue untill there is no more numbers. So again, I wnat to step through all my random numbers and delete the ones I have displayed.
not after code, just thoughts, suppose i'm generating a random 8-digit pin number for our clients, first i'll be checking against the db to see if it already exists before assigning it. what i might do for that is getstring all of the exsiting pins at the top of the script and just keep performing an instr until i get a 0. (i dont expect to ever go above a thousand clients for this system and hopefully my initial number will be random enough that these checks are for backup/redundancy assertion anyway)
but anyway, the main problem is: i dont want to generate a random pin that is one (or maybe two) digit(s) different from another,. i.e.
11111111 is too close to 14115111 and much too close to 11111811. 11121111 is right out of the question as it can be entered as a typo, as is 11111411 because of the numpad
so i'm after thoughts on how to perform that check, i suppose if i went with the "big string of all pins that went before" check i could perform a number of regex searches on the string. i.e.
my pin is 12345678 and i dont want ony to be one digit different so i'd check the string against .2345678 1.345678 12.45678 and so on. think i just answered my own question, anyone else got any ideas? especially for the two digit case (dont want to be performing 36 regex checks do i!)
I am trying to write an array of random numbers to a database. The array part is working fine, but when I go to update the dataabse, it inserts the last value of the array into all the fields in the database .....
Dim MyValue,sqlRandom Dim arrayRandom(8) for i = 1 to 8 Randomize MyValue = Int((100 * Rnd) + 1) arrayRandom(i) = MyValue response.write "<p> Array Value:" & arrayRandom(i)
Ok here is what I'm trying to do. I want to grab a random record from a specific table. This is how I am doing it now:
x = 0 Set rs = Conn.Execute("SELECT Count(*) as total FROM [user] WHERE active = '1'") If rs.EOF <> True then total = rs("total") End if Randomize timer randnum1 = int(rnd * total) If randnum1 = 0 then randnum1 = 1 End if rs.close set rs = nothing
Set rs = Conn.Execute("SELECT * FROM [user] WHERE id = '" & randnum1 & "' ") Now that would work fine, BUT the id is a autonumber int of 1.
Now look at this example. Let's say I have 50 records, so I have the ID values of 1 through 50. Now I delete record number 46. So now my count goes up to 49. So the random number will pull up ANY number between 1 and 49, so if it pulls up 46 then BAAAM record can not be found.
There has to be an easier/more efficient way of getting a random record. I don't plan on deleting any records, but I just don't feel this is the best way of doing this.
I want to select 5 random records from my database..I tried to suft the net and foundout this sql
SELECT TOP (3) Question, Choice1, Choice2, Choice3, Choice4 FROM Question
But when i tried to execute,i t always gave me the most top 2 records. why?Is this sql statement woring?How can i select 5 random records from the database?
<% Dim oConn, oRS, randNum Randomize() randNum = (CInt(1000 * Rnd) + 1) * -1 Set oConn=Server.CreateObject("ADODB.Connection") Set oRS=Server.CreateObject("ADODB.recordset") oConn.Provider="Microsoft.Jet.OLEDB.4.0" oConn.Open Server.MapPath("temp.mdb")
oRS.Open "SELECT TOP 1 EMAIL_ADDRESS, r = Rnd(" & randNum & ") FROM TABLE1 ORDER BY r", oConn, adOpenStatic, adLockReadOnly
Response.Write oRS("EMAIL_ADDRESS")
oRS.close oConn.close Set oConn = nothing Set oRS = nothing %>
this gives the error: "No value given for one or more required parameters".
what i would really LOVE is for someone to fill in whatever required parameter im missing, but more important i would like to understand whats going on. there are people who go through life dumb and happy once something "works", but i need to understand how and why its working. even if this code did work, im confused with the SELECT statement (no, i dont have much SQL experience aside from basic queries). what is the "r = Rnd" line doing in the middle of the querie? how am i ordering by r?? also, i dont have an indexed, primary "ID" field in this databae. is that ok for this code to work?
I'm probably doing something wrong here but when I try to get onlyl the records which occur after today's date, I get all of the records from the table, before and after today's date. Code:
Is there a possibilty to use the function <SELECT NAME="user"><OPTION>user 1</OPTION></SELECT> from a database. I want to get the data out from a table and store the data from that column in a dropdown box. What's the way to do this ?