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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:02:23+00:00 2026-06-10T06:02:23+00:00

I have this postgresql code. SELECT * FROM listings WHERE status != ‘inactive’ ORDER

  • 0

I have this postgresql code.

SELECT * 
FROM listings 
WHERE status != 'inactive' 
ORDER BY pkey DESC LIMIT 1000 OFFSET 0

Precisely, this will query the FIRST 1000 listings which is still active then sort it DESC.
Is there a best way to query the most recent/latest data?
Like for example I have a 500000 rows, now when I executed the query I want the 499000-500000 to be queried DESC.

Thanks for the help.

  • 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-10T06:02:24+00:00Added an answer on June 10, 2026 at 6:02 am

    Just to mince words, you said

    this will query the FIRST 1000 listings which is still active then sort it DESC

    Which is not accurate. It will sort sort id DESC and then select the “first” 1000 (which, when sorted DESC can be thought of as the “last” 1000).

    So, I think the answer to your question is in your question. The query you show will select the “last” (i.e. the records with the greatest values in column ‘pkey`) 1000 records, ordered from the most recent to the one a thousand ago.

    Note that the only real caveat is that it’s not exactly 499000-500000, which would only be true if all 1,000 most-recent rows are “active”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: SELECT tblschemeprojectpaymentgateway.paymentgatewayid, paymentgatewayname FROM + tblschemeprojectpaymentgateway INNER JOIN tblpaymentgateway ON
Assume that you have this code in C#/.NET (using PostgreSQL via ODBC): using System.Data.Odbc;
I have this postgres sql query: select * from stats where athlete_id = 5
So, I have this PHP code: $tabid = getTabid($module); if($tabid==9) $tabid=9,16; $sql = select
I've done a query like this : SELECT Code, kind, SUM(valP) AS value FROM
I'm using PostgreSQL 9.1 and I have this data structure: A B ------- 1
I have a table in my postgresql 8.4 database like this: id(serial), event_type_id(id, foreign
In my Postgresql database, I have a timestamp without time zone with this value
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
Question: I want to test an if statement in PostgreSQL: IF (SELECT COUNT(*) FROM

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.