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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:11:31+00:00 2026-05-29T15:11:31+00:00

Consider the following query: INSERT INTO statement_line_items SELECT count(*)::integer as clicks, sum(amount_cents)::integer as amount_cents,

  • 0

Consider the following query:

INSERT INTO     statement_line_items
SELECT      count(*)::integer as clicks, sum(amount_cents)::integer as amount_cents, imps.user_id, imps.created_at::date as statement_date
FROM        impression_events imps
INNER JOIN  transactions t ON t.event_id = imps.id
  AND       t.event_type = 'ImpressionEvent'
  AND       amount_cents >= 0
WHERE       imps.created_at >= (now() - interval '8 days')::date
  AND       imps.created_at < (now() - interval '7 day')::date
  AND       imps.clicked = true
GROUP BY    imps.user_id, imps.created_at::date;

This is returning:

ERROR:  column "statement_date" is of type date but expression is of type integer
LINE 2: ...icks, sum(amount_cents)::integer as amount_cents, imps.user_...
                                                             ^
HINT:  You will need to rewrite or cast the expression.

********** Error **********

ERROR: column "statement_date" is of type date but expression is of type integer
SQL state: 42804
Hint: You will need to rewrite or cast the expression.
Character: 117

My table structure for statement_line_items is:

"id";              "integer"
"user_id";         "integer"
"statement_date";  "date"
"description";     "character varying(255)"
"clicks";          "integer"
"amount_cents";    "integer"
"created_at";      "timestamp without time zone"
"updated_at";      "timestamp without time zone"
  • 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-29T15:11:32+00:00Added an answer on May 29, 2026 at 3:11 pm

    You are putting the imps.userid in your statement_date column. That has to fail.

    count(*)::integer as clicks                   goes into id
    sum(amount_cents)::integer as amount_cents    goes into userid
    imps.user_id                                  goes into statement_date
    

    To specify the order you are inserting you can do this:

    INSERT INTO statement_line_items (col1, col2, ...)
    SELECT data_for_col1, data_for_col2, ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following sql server query , DECLARE @Table TABLE( Wages FLOAT ) INSERT
Consider the following 3 standard statements $queryString = SOME SQL SELECT QUERY; $queryResult =
I need help with a query. Consider the following table: I need to select
Please consider the following: $query = SELECT legIDs FROM trip; $result = mysql_query($query) or
Consider the following SQL Server 2005/2008 query: Select [UID], [DESC] From SomeTable Order By
Consider the following JPQL query: SELECT foo FROM Foo foo INNER JOIN FETCH foo.bar
Consider the following query in PostgreSQL: SELECT a, b, (A VERY LONG AND COMPLICATED
I have the following MySQL query: SELECT SUM(IF(num_content>3,3,num_content)) FROM ( SELECT DATE(FROM_UNIXTIME(content_timestamp)) as dt,
Consider the following query: SELECT operation, [...] FROM tableName The operation field will retrieve
Consider the following query: SELECT domain, done FROM tasks WHERE 1 GROUP BY domain

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.