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

  • Home
  • SEARCH
  • 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 6561085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:32:39+00:00 2026-05-25T13:32:39+00:00

I have a statistical table in PostgreSQL table: article_id | date | read_count 1

  • 0

I have a statistical table in PostgreSQL table:

article_id | date       | read_count
    1      | 2011-06-02 | 12
    1      | 2011-06-03 | 54
    1      | 2011-06-04 | 2
    1      | 2011-06-05 | 432

And as i need this data in a chart, i need to get values in each week.

I know Postgres has a row_number() function, anyway i didn’t get it to work properly.

SELECT "date", "read_count" FROM "articles_stats" 
WHERE row_number() OVER (ORDER BY "date" ASC) % 7 = 0
ORDER BY "date" ASC

ERROR: window functions not allowed in WHERE clause

  • 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-25T13:32:39+00:00Added an answer on May 25, 2026 at 1:32 pm

    From @pst‘s link,

    “If there is a need to filter or group rows after the window
    calculations are performed, you can use a sub-select.”

    For example:

      SELECT * 
        FROM (
              SELECT "date", "read_count", 
                     row_number() OVER (ORDER BY "date" ASC) as n
                FROM "articles_stats" 
             ) x
       WHERE x.n % 7 = 0
    ORDER BY x."date" ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

say I have a postgresql table with the following values: id | value ----------
I have a name of table or view in PostgreSQL database and need to
I have a table for a Statistical project. Structure is like this: CREATE TABLE
I have data in a mysql table in long / tall format (described below)
We have an R Server (R is a programming language used in statistical analysis)
For statistical reasons, I want an extensive analysis from a dataset. I already have
PostgreSQL stores statistics about tables in the system table called pg_class. The query planner
I have a table with a billion rows and I would like to determine
I have the following database table with information about people, diseases, and drugs: PERSON_T
I have a table in an Oracle database that contains actions performed by users

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.