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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:28:21+00:00 2026-05-25T02:28:21+00:00

Can someone help me convert this sqlite query to a postgres query? SELECT count(*),

  • 0

Can someone help me convert this sqlite query to a postgres query?

SELECT count(*), count(*), date(date, '-'||strftime('%w',date)||' days') as date
FROM emails as m, contacts as me
WHERE datetime(date) > datetime('2010-08-25')
  and datetime(date) < datetime('2011-08-25')
  and (me.id = m.fr)
  and me.email like '%gmail.com%'
GROUP BY date
ORDER BY date asc

update, I found the answer:

select count(*), (m.date::date - extract(dow from m.date)::int) as dat
from emails as m join contacts as me on m.fr = me.id
where m.date > '2010-08-25'
  and m.date < '2011-08-25'
  and me.email like '%gmail.com%'
group by dat
order by dat
  • 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-25T02:28:21+00:00Added an answer on May 25, 2026 at 2:28 am

    The strftime business was taken care of elsewhere so we only have to sort out the datetime(...) stuff here and compensate for date being a timestamp. And I’ll switch to an explicit join condition (rather than the implicit one in the WHERE clause) while I’m here.

    select count(*), count(*), m.date::date - extract(dow from m.date)::int as date
    from emails as m join contacts as me on m.fr = me.id
    where m.date > '2010-08-25'
      and m.date < '2011-08-25'
      and me.email like '%gmail.com%'
    group by m.date
    order by m.date asc
    

    PostgreSQL can compare timestamps with ISO8601 date strings on its own so you don’t need any casting or reformatting for the comparisons.

    The two count(*) still look a bit funny to me but I don’t know the context that the query is used in so the duplicates might make sense.

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

Sidebar

Related Questions

Hi can someone help me convert this tsql statement into c# linq2sql? select [series]
Can someone please help to convert this to linq? SELECT x.contentobjectid, Min(x.city) as city,
Can someone help me understand how to convert this sql query to a named_scope
I am new to SQL. Can someone help to convert this query, so it
Can someone help me identify what the purpose of this unidentified syntax is. It
As a follow-up to this question I am hoping someone can help with the
Can someone please help me convert the following two lines of python to C#.
Can someone please tell me how to convert this to razor view syntax? <%=
I'm currently working with Zend framework and I need help to convert this query
Can someone help me convert the following code into code that instead has two

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.