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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:05:12+00:00 2026-06-16T04:05:12+00:00

I believe I a fairly simple question that I can not locate here on

  • 0

I believe I a fairly simple question that I can not locate here on Stack or out in Google land. I have a fairly basic select statment that’s something like this:

SELECT
    itemid,
    itemdiscription,
    SUM(quantity)
FROM     mytable
GROUP BY itemid, itemdescription
ORDER BY itemid
LIMIT    250
OFFSET   0;

Basicly this is pulling from a table of over 100k + records or so, or less depending, it’s a temporary table. So what I’m trying to figure out is the SUM function providing reliable data, because there could 30k records between similar item ids. My initial thought was this would preform the query and then return only the first 250 results, but then I got to thinking maybe not, so I thought I’d ask the community for comfirmation on how this works.

The main reason I’m using LIMIT/OFFSET is because I’m preforming the query from PHP and those values are variables that are iterated for preformance so I’m not dealing with an Array that uses mass amounts of memory.

Thanks!

  • 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-16T04:05:14+00:00Added an answer on June 16, 2026 at 4:05 am

    As the docs state, the limit (or offset) apply to “the rows that are generated by the rest of the query”, so consider the result of the query prior to the application of limit or offset. Applying these clauses then affects these results.

    http://www.postgresql.org/docs/9.2/static/queries-limit.html

    Here’s a SQL Fiddle of a couple of ways of using LIMIT

    http://www.sqlfiddle.com/#!12/08fa0

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

Sidebar

Related Questions

I believe this is a fairly simple question but I have no idea where
My question, I believe, is fairly simple but I can't seem to find a
I believe this is a fairly simple question but it is something I am
I have what I believe is a fairly simple application at the moment based
Just out of curiosity, for applications that have a fairly complicated module tree, would
I have a method that copies one stream into another. It's fairly simple and
I am trying to do something that I believe is fairly simple. On page
This should be a fairly simple question. Essentially, I believe there's a good chance
I have a fairly simple desktop application that uses a .NET setup project (.msi
I'm sure there is a fairly simple answer to this question, so here we

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.