Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7544295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:38:22+00:00 2026-05-30T08:38:22+00:00

We have had a request to provide some data to an external company. They

  • 0

We have had a request to provide some data to an external company.
They require only a sample of data, simple right? wrong.

Here is their sampling criteria:

  • Total Number of records divided by 720 (required sample size) – this gives sampling interval (if result is a fraction, round down to next whole number).

  • Halve the sampling interval to get the starting point.

  • Return each record by adding on the sampling interval.

EXAMPLE:

  • 10,000 Records – Sampling interval = 13 (10,000/720)
  • Starting Point = 6 (13/2 Rounded)
  • Return records 6, 19 (6+13), 32 (19+13), 45 (32+13) etc…..

Please can someone tell me how (if) something like this is possible in SQL.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:38:23+00:00Added an answer on May 30, 2026 at 8:38 am

    If you have use of ROW_NUMBER(), then you can do this relatively easily.

    SELECT
      *
    FROM
    (
      SELECT
        ROW_NUMBER() OVER (ORDER BY a, b, c, d) AS record_id,
        *
      FROM
        yourTable
    )
      AS data
    WHERE
      (record_id + 360) % 720 = 0
    

    ROW_NUMBER() gives all your data a sequential identifier (this is important as the id field must both be unique and NOT have ANY gaps). It also defines the order you want the data in (ORDER BY a, b, c, d).

    With that id, if you use Modulo (Often the % operator), you can test if the record is the 720th record, 1440th record, etc (because 720 % 720 = 0).

    Then, if you offset your id value by 360, you can change the starting point of your result set.

    EDIT

    After re-reading the question, I see you don’t want every 720th record, but uniformly selected 720 records.

    As such, replace 720 with (SELECT COUNT(*) / 720 FROM yourTable)

    And replace 360 with (SELECT (COUNT(*) / 720) / 2 FROM yourTable)

    EDIT

    Ignoring the rounding conditions will allow a result of exactly 720 records. This requires using non-integer values, and the result of the modulo being less than 1.

    WHERE
      (record_id + (SELECT COUNT(*) FROM yourTable) / 1440.0)
      %
      ((SELECT COUNT(*) FROM yourTable) / 720.0)
      <
      1.0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far I have been creating Web Portal but recently I had a request
I have had a bug recently that only manifested itself when the library was
I have had a hard disk failure which resulted in some files of a
I have had many requests come in to a project that I work on,
Have had to write my first proper multithreaded coded recently, and realised just how
We have had SharePoint where I work for a little while now, but we've
I have had to do this several times, usually when trying to find in
We have had issues with Mootools not being very backward compatible specifically in the
I have had a few problems with log files growing too big on my
We have/had a phantom delay in our app. This was traced to the initialisation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.