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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:22:29+00:00 2026-06-17T17:22:29+00:00

can someone please help me with this sql query. it gives me a 1064

  • 0

can someone please help me with this sql query. it gives me a 1064 error suggesting I have a syntax error in my query. I’ve looked for the error over 2 hours now and getting frustrated now.

SELECT 
 SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 6 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 5 MONTH)), earnings, 0)) AS Rev5,
 SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 5 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 4 MONTH)), earnings, 0)) AS Rev4,
 SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 4 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 3 MONTH)), earnings, 0)) AS Rev3,
 SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 3 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 2 MONTH)), earnings, 0)) AS Rev2,
 SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 2 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 1 MONTH)), earnings, 0)) AS Rev1,
 SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 1 MONTH)) AND (`date` < ?), earnings, 0)) AS Rev0
FROM
 hat_adsense_stats
GROUP BY 
 domain
ORDER BY
 domain

thanks here is the error:

Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘?, INTERVAL 1 MONTH)) AND (date < ?), earnings, 0)) as Rev0
FROM
hat_adsens’ at line 2

  • 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-17T17:22:30+00:00Added an answer on June 17, 2026 at 5:22 pm

    You have parameter place holders on your query, which do not work on pure sql. The only time ? works is when you create a Dynamic SQL.

    If you are working with query that is not a Dynamic SQL, you should provide a value for that.

    On example to remove the syntax error on the statement is to create a user variable, eg

    SET @date = CURDATE();
    SELECT 
     SUM(IF( (`date` >= DATE_SUB(@date, INTERVAL 6 MONTH)) AND (`date` < DATE_SUB(@date, INTERVAL 5 MONTH)), earnings, 0)) AS Rev5,
     SUM(IF( (`date` >= DATE_SUB(@date, INTERVAL 5 MONTH)) ........
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please help me tune this SQL query? SELECT a.BuildingID, a.ApplicantID, a.ACH, a.Address,
can someone please help me. why does this return an error: Dim stuff As
I hope someone can help with this please. I am trying to query an
Can someone please help? Here is my jQuery. The scenario is this, I have
Can someone please help me out with a query? In Microsoft SQL Server, I
Can someone please help me out with a JavaScript/jQuery solution for this arithmetic problem:
Could someone please help explain why I can't get this to work? I properly
Im a beginner to css, please can someone help me get this element to
this kind of emergency, so please, can someone help me... I'm using movingboxes plugin
please could someone help me with this. I can't seems to get my mind

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.