Title: SQL query appears incorrect?
Last modified: August 30, 2016

---

# SQL query appears incorrect?

 *  [WPChina](https://wordpress.org/support/users/wordpresschina/)
 * (@wordpresschina)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/sql-query-appears-incorrect/)
 * I’m using the following SQL code query to return a chart of the posts published
   each day:
 *     ```
       select
       count(*) as total_posts ,
       date(post_date) as posted_date
       from wp_posts
       group by posted_date
       having total_posts > 0
       ```
   
 * However, it returns a chart with a flat line. The WordPress installation has 
   about 11,000 posts over a 10 year period, and the line should not be flat since
   some days there are zero posts and some days there are 20 posts. What am I doing
   wrong in the sql query?
 * [https://wordpress.org/plugins/wp-business-intelligence-lite/](https://wordpress.org/plugins/wp-business-intelligence-lite/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [claudio](https://wordpress.org/support/users/calberti/)
 * (@calberti)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/sql-query-appears-incorrect/#post-6756006)
 * Hi, when you test the query do you get a correct result? You should see the result
   in a table with the first 20 elements.
 *  Thread Starter [WPChina](https://wordpress.org/support/users/wordpresschina/)
 * (@wordpresschina)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/sql-query-appears-incorrect/#post-6756008)
 * Yes that’s why it’s odd that it’s not displaying the chart correctly. Weird.
 *  [claudio](https://wordpress.org/support/users/calberti/)
 * (@calberti)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/sql-query-appears-incorrect/#post-6756009)
 * When displaying the chart do you get any error message in the JS console? (shift
   +ctrl+I)
 *  Thread Starter [WPChina](https://wordpress.org/support/users/wordpresschina/)
 * (@wordpresschina)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/sql-query-appears-incorrect/#post-6756067)
 * Hi yes in Chrome I see this error in JS Console for nv.d3.min.js:1 (total 894).
   What else should I look at for troubleshooting?
 *  [claudio](https://wordpress.org/support/users/calberti/)
 * (@calberti)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/sql-query-appears-incorrect/#post-6756097)
 * I think there might be a problem with the data format. You can have a look at
   the page source (ctrl+U) and see the json file with the data series.
    You can
   as well reduce the time span just to see if it works with less data and then 
   you increase it little by little.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘SQL query appears incorrect?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-business-intelligence-lite_eae8f9.
   svg)
 * [WP Business Intelligence Lite](https://wordpress.org/plugins/wp-business-intelligence-lite/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-business-intelligence-lite/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-business-intelligence-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-business-intelligence-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-business-intelligence-lite/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [claudio](https://wordpress.org/support/users/calberti/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/sql-query-appears-incorrect/#post-6756097)
 * Status: not resolved