I want to return random records in term of time whithout NEWID
View Complete Post
You got to love management, they can never make their minds up on what they want.
I'm currently working on a asp.net project using a datagridview that acts for the most part like a spreadsheet. What I have to do now is update all the values in the table from the selected date, hour, min, max and cost forward. There are 7 days worth of data in the table, when the user alters either the min, max or cost I need all the values in that field from that point onward to have the new altered value.
Here's an example:
In hour 10 of the day the user want to increase the max from 5 to 19, the min stays the same and so does the cost. Mind you any or all of these values could change. The only once that will remain as-is is the Date and Hour field:
I am developing a College exam system where Teacher will upload questions, students will login and solve the answers.
Here suppose, faculty(any) uploads 500 questions. When exam starts then students will login. Ofcourse not on the SAME TIME. There is a button start my exam. When he/she press the button exam will start for particular student. All 500 questions are uniqe for every students. None of question repeated to anyone. So, If Student 'B' logs in first then he'll get 1st question only and after that if student 'A' logs in then he will get 2nd question. Like same for every student.(First come first service based) When any question will finish he'll press next button then again random question will genrate.
Here, if question is delivered to any student then this question will not be displayed again to anyone.
I become confuse how to do that. Just tell me the idea regarding this.
i try to use select statement to select records within a week from orderdate. like,
"select * from order where orderdate <= DATEADD(day,7,orderdate)";
correct me if wrong.
I have a question about a select statement. Currently I have a select statement that does what I want it to do, but it needs to be altered, giving my WHERE options an equal chance to show.
SELECT TOP 1 *, NEWID() as Random
WHERE CODE = 'AB' OR CODE = 'ABC'
ORDER BY Random
It seems to work pretty well for the purpose. Often I will need 3 to 6 different Code types. What I need it to do is give each CODE type an equal oportunity to display.
I have WHERE CODE = 'AB' OR CODE = 'ABC' OR CODE = 'ABCD'
I'd like them to, in this instance, have a 33% to show. More or less, I'd like, 1 of AB, ABC, ABCD, then I want them to randomize agian.
If I have 4 Code types, I'd like a Select statement to grab 1 of each, and give them a 25% chance to show, by randomizing those 4.
Suppose, I have a table with the following data. I need to be able to select the unique records from this table, on the LogicalHash column. However, I need the select the largest by FileSize. I can't quite figure out the correct
SQL for this. If I didn't have to worry about taking the largest file, I would just do this:
SELECT * FROM files
WHERE FileID in (
SELECT max(FileID) FROM files GROUP BY LogicalHash)
How do pick the largest file? The file size is not going to be unique throughout the table, I can't select based on that. Using cursors sounds like a bad idea. I also need the SQL to be somewhat backwards compatible to MS Access.
I have a form that is doing a simple insert, then a sub insert of a certain drop down selection is made. What i dont get is why the main insert is inserting duplicates and the sub works fine inserting 1 record per text as expected. I click the button 1 time, and when i check the table, there are 2 new records.. As you can see the insert is not wrapped with any conditions, once that is inserted i check if a slection was made and runs the sub insert.
My full code can be found in this post(http://forums.asp.net/t/1608619.aspx), but here is what i have for my button event.
protected void btnSaveServConfig_Click(object sender, EventArgs e)
dac.insertServerConfigintosql(txtEmailLogin, txtEmailPass, Convert.ToInt32(ddlNumEmail.SelectedValue));
if (Convert.ToInt32(ddlNumEmail.SelectedValue) > 0)
Dictionary<string, string> camValues = new Dictionary<string, string>();
foreach (HtmlTableRow row in table1.Rows)
foreach (HtmlTableCell cell in row.Cells)
foreach (Control control in cell.Controls)
I need to find rows in a table that have StartTime and EndTime that fall between sent start and end time parameters. Below is the design of the table I want to search and below it is an example of a SELECT statement. I need to add to the SELECT
another condition (e.g. AND StartTime BETWEEN @StartTime AND @EndTime OR EndTime BETWEEN @StartTime AND @EndTime). Any help is appreciated.
CREATE TABLE [dbo].[CareScheduleDetail](
[CareScheduleDetailID] [int] IDENTITY(1,1) NOT NULL,
[CareScheduleID] [int] NOT NULL,
[WorkDay] [tinyint] NOT NULL,
[StartTime] [time](7) NULL,
[EndTime] [time](7) NULL,
[SvcType] [varchar](4) NULL,
[Effective] [date] NULL,
[Ended] [date] NULL)
SELECT WorkDay, StartTime, EndTime
WHERE (Ended IS NULL)
I have a database with a GUID and images,
I want to get the first record (if exists) and return results
i want to get the second record only if a second record exists
I guess I have to return the records frmo the table then just movenext so to speak in a loop to select the second record but guessing there is a better faster way to do that in linq
I see some example for .take(1) I assume that will always take the first record and return nothing else. I dont need this to be random. and what happens if there are no records return?
for the second function
I gues its .skip(1).take(1) will that for sure skip the first record and return the second one to my var? again what if thier is no second record i would not want any results return if this is not the case (no scond record then want nothing back and no error)
How to Retrive records within last 24 hrs using Nhibernate.I want to retrieve the 10 records within last 24 hours.
How can i achieve this using Nhibernate.
Hi, I have a strange time out issue on a simple select statement.
This is my select statement:
Select * from DyGeJournal where ord>=4609635 and Fracsec>=31
The ord and Fracsec is the primary key.
When I ask for the actual excecution plan, he is using a an index seek.
It takes more than 1,5 minutes to get a result back.
When I shrink my database, everyting is running as expected, the query above runs in milliseconds.
After a while (2 weeks) it start agian running very slow.
I have the same logic on other tables, but I don't have the problem on those tables.
What can cause this problem?
i have a select statement which returns a column value.
id like to display the lowest column value there is, but if there are multiple rows with the same (and lowest) value id like it to be random which one of the rows is selected.. how would i do this? my select statement is currently:
SELECT TOP (1) url, ABS(r1 - @r1) + ABS(r2 - @r2) AS differenceFROM typeORDER BY difference
this picks the one lowest result for me, but if there are multiple duplicate lowest results id like to select them, and show one at random..?
Having problems coding a query.
Got a list box that allows for multiple selections (holding down the control key) the selection quantity is basically unlimited, but should never be more than 50 to 100 items from the listing of about 3000 items.
How can I code the SQL statement to select the choosen record data? I think I have the selection list worked out by populating an array but I am not clear on how to build the SQL query.
Any help would be appreciated.
I have three table and SELECT DELETE INSERT UPDATE happening at the same time.
Join query is used for SELECT and DELETE.
INSERT and UPDATE no join query.
What are the actions to be taken to avoid deadlock. Will indexing help to resolve the dead lock.
Appreciate somebodys help immediately.