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 8780293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:00:21+00:00 2026-06-13T20:00:21+00:00

I have the following SQL query which I use to fetch some rows from

  • 0

I have the following SQL query which I use to fetch some rows from a mySQL database :

SELECT code_ver, result FROM mastertest WHERE date >= DATE_SUB( (CURDATE()) , INTERVAL 90 DAY) ORDER BY date DESC;

This query gives me data from the past 90 days. Now I want to display the data of 10 days at a time in my html.erb page (view). I am aware that pagination can be done using ‘will_paginate’ and ‘kaminari’ gems. But I am not sure how to query the database with certain conditions as shown above.

Can someone help me with the code here?

  • 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-06-13T20:00:23+00:00Added an answer on June 13, 2026 at 8:00 pm

    This is how you could construct that in ActiveRecord:

    Mastertest.where('date >= ?', Time.now - 90.days ).order('date DESC').select("code_ver, result")
    

    From here, you can either chain will_paginate or kaminari methods, or roll your own if you want. You may want to roll that query into a class method if you will be using it a lot:

    class Mastertest
      def self.last_90_days
        where('date >= ?', Time.now - 90.days ).order('date DESC').select("code_ver, result")
      end
    
      ## here's a simple pagination example:
      def self.page(page,per_page)
        limit(per_page).offset((page - 1) * per_page)
      end
    
    end
    
    Mastertest.last_90_days.page(1,20) #=> [...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following which works in SQL Query Analyzer . select oh.* from
I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
i have the following sql query select * from tblArea where AreaDescription in ('Processing1','Geology
I have the following SQL query: SELECT * FROM table WHERE field_1 <> field_2
I have following SQL Query SELECT * FROM KDMS_dynamic vd INNER JOIN KDMS_definition tblKDMS
I have following somewhat complex sql query which has horrible performance, 'certainly' due to
I have a drop-down list which is generated based on the following sql query:
I have the following SQL query: SELECT r.BEZEICHNUNG AS BEZEICHNUNG, r.ID AS ID, ra.BEZEICHNUNG
I have the following SQL query SELECT r.BEZEICHNUNG AS BEZEICHNUNG, r.ID AS ID, ra.BEZEICHNUNG
Let's say I have the following SQL query SELECT id, name, title, description, time

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.