2

How do I use the count (*) function within a set date parameter? I have a table of order records and I would like to only count the ones for a specific date.

My Query was

SELECT COUNT (*) 
FROM bets
WHERE order_date='2018-01-22';

And that returned this

1 queries executed, 0 success, 1 errors, 0 warnings

cQuery: SELECT COUNT (*) FROM bets WHERE order_date='2018-01-22' LIMIT 0, 1000

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 '*) FROM bets WHERE order_date='2018-01-22' LIMIT 0, 1000' at line 1

Execution Time : 0 sec Transfer Time : 0 sec Total Time : 0.021 sec

3 Answers 3

4

Remove the space between count and ()

SELECT COUNT(*) ...
Sign up to request clarification or add additional context in comments.

Comments

0

The above works in Postgres, mysql needs set sql_mode = "IGNORE_SPACE";.

That why this gives you an error there two way either you can remove space or set sql_mode.

Comments

-1

I have tried and mentioned query is working for me:

SELECT count(*) FROM "**TABLENAME**"  where  DATE_FORMAT(**columnName**,'%Y-%m-%d') = '2017-08-02'; 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.