Question
How to select a random record from a table?

Answers

There is no such feature in Firebird, but you can use some tricks. The following example requires that you have a unique integer column (primary key is usually used):
SELECT.. field_list...
FROM table t1
WHERE conditions
ORDER BY (t1 .int_col + seed)*4294967291 -((tl .int_col + seed)*4294967291/49157)*49157;
If you just need one random record, limit the result set using FIRST or ROWS clause. This query will give consistent records for the same seed. If you wish to be completely random, you need to change the seed. You could use the value of int_col from previous run, or simply fetch a new value from a generator (just make sure the same value for seed is used in both places in expression).   Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q With an unchecked exception, In fact, client programmers may not even know that the exception could be thrown. However, the compiler doesn't force client programmers either to catch the exception or declare it in a throws clause. eg, StringIndexOutOfBoundsException thrown by String's charAt() method Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be.
  • Q What is import all data feature in tableau?
  • Q Full form CAG
  • Q Who was Barbara Streisands first husband
  • Q In which Five Year Plan University Grants Commission was set up for promoting and strengthening higher education?
  • Q How will you calibrate an absolute pressure transmitter vaccum manometer Range 0-400mm abs ?
  • Q What is adjustment?
  • Q How to return XML from the stored procedure in SQL SERVER?
  • Q What is runnable?
  • Q Display the half of the enames in upper case and remaining lower case.
  • Q A colectomy specimen from a 35-year-old female with history of intermittent attacks of mild diarrhea with fever and abdominal pain, shows “skip lesions” in the form of sharply demarcated areas of ulceration and fissuring, also involving the distal ileum. What features would you expect to find on microscopic examination of the diseased segments? What are the three main types of liver disease associated with chronic consumption of alcohol?