Title: Using SQL Query for Count
Last modified: March 15, 2022

---

# Using SQL Query for Count

 *  [cnasal](https://wordpress.org/support/users/cnasal/)
 * (@cnasal)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/using-sql-query-for-count/)
 * I’m trying to use the option **SQL Query for Count** due to a large query timing
   out. I added to that input box a simple query like the following, which removed
   all the related fields I am pulling in my main SQL Query:
 *     ```
       SELECT id
       FROM wp_posts AS locations
       WHERE  %%WHERE%% locations.post_type = 'location'
       ```
   
 * However, when I run the report, it only shows 25 total results. Should I be querying
   count(*) or something else in order for it to return a total count to be used?
   Could you give me an example query to use for **SQL Query for Count**?
 * Thanks!
    Carl
    -  This topic was modified 4 years, 1 month ago by [cnasal](https://wordpress.org/support/users/cnasal/).

The topic ‘Using SQL Query for Count’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/exports-and-reports.svg)
 * [Exports and Reports](https://wordpress.org/plugins/exports-and-reports/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/exports-and-reports/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/exports-and-reports/)
 * [Active Topics](https://wordpress.org/support/plugin/exports-and-reports/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/exports-and-reports/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/exports-and-reports/reviews/)

## Tags

 * [count](https://wordpress.org/support/topic-tag/count/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * 0 replies
 * 1 participant
 * Last reply from: [cnasal](https://wordpress.org/support/users/cnasal/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/using-sql-query-for-count/)
 * Status: not resolved