> [!NOTE]
> **Note:** For significantly better performance and efficient batch processing, use [`PLACES_COUNT_PER_TYPE_V2`](https://developers.google.com/maps/documentation/placesinsights/place-count-functions/places-count-per-type-v2.md.txt).

The `PLACES_COUNT_PER_TYPE` function returns a table of counts for each place
**type** specified to the function. For example, if you search for the types
`doctor`, `hospital`, and `pharmacy` the response contains a table with a
separate row for each type.

> [!NOTE]
> **Note:** If you specify these same three types to the `PLACES_COUNT` function, `PLACES_COUNT` returns a single value containing the combined count for all three types.

Because the `PLACES_COUNT_PER_TYPE` function returns a table, call it using a
`FROM` clause.

- Input parameters:

  - **Required** : The `geography` [filter parameter](https://developers.google.com/maps/documentation/placesinsights/place-count-functions/filter-params) that
    specifies the search area. The `geography` parameter takes a value
    defined by the BigQuery
    [`GEOGRAPHY`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#geography_type)
    data type, which supports points, linestrings, and polygons.

    For examples of using different types of search geographies, such as
    viewports and lines, see [`PLACES_COUNT`
    function](https://developers.google.com/maps/documentation/placesinsights/experimental/places-count).
  - **Required** : The `types` [filter parameter](https://developers.google.com/maps/documentation/placesinsights/place-count-functions/filter-params) that
    specifies the place types to search for.

  - **Optional** : Additional [filter](https://developers.google.com/maps/documentation/placesinsights/place-count-functions/filter-params) parameters to refine
    your search.

- Returns:

  - A table with one row per `types` value. The table contains the columns
    `type` (`STRING`), `count` (`INT64`), and `place_ids`
    (`ARRAY<STRING>`) where `place_ids` contains up to 250 place IDs
    for each `type`.

    > [!NOTE]
    > **Note:** The returned table contains one row per `types` value. While you can use `primary_types` as a filter, the results are only grouped by `types`.

## Example: Return count of restaurant, cafes, and bars

In this example, you search for all operational restaurant, cafe, and bars in
the specified search area defined as a polygon in New York City.

The `types` parameter takes an array of `STRING` values specifying the place
types to search for. For the complete list of possible values, see
[Place types](https://developers.google.com/maps/documentation/placesinsights/place-types.md.txt).

This example also uses the BigQuery
[`ST_GEOGFROMTEXT`](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_geogfromtext)
function to return a `GEOGRAPHY` value from a polygon.

```googlesql
DECLARE geo GEOGRAPHY;
SET geo = ST_GEOGFROMTEXT('''POLYGON((-73.985708 40.75773,-73.993324 40.750298,
                                      -73.9857 40.7484,-73.9785 40.7575,
                                      -73.985708 40.75773))''');  -- NYC viewport

SELECT * FROM `PROJECT_NAME.places_insights___us.PLACES_COUNT_PER_TYPE`(
  JSON_OBJECT(
      'types', ["restaurant", "cafe", "bar"],
      'geography', geo,
      'business_status', ['OPERATIONAL']
      )
);
```

This function returns a table with three rows, one per type:

![Results for Places Count Type function in New York City.](https://developers.google.com/static/maps/documentation/placesinsights/images/place_count_type_func.png)

## Example: Return counts per type filtered by brand

The following example uses the `brand_ids` filter to retrieve type counts for
specific brands, such as Starbucks with the ID `"1413758728321880760"`:

```googlesql
DECLARE geo GEOGRAPHY;
SET geo = ST_GEOGFROMTEXT('POLYGON((-73.985708 40.75773,-73.993324 40.750298,
                                      -73.9857 40.7484,-73.9785 40.7575,
                                      -73.985708 40.75773))');  -- NYC viewport

SELECT * FROM `PROJECT_NAME.places_insights___us.PLACES_COUNT_PER_TYPE`(
  JSON_OBJECT(
      'types', ["cafe", "restaurant"],
      'geography', geo,
      'brand_ids', ["1413758728321880760"], -- Filter for Starbucks
      'business_status', ['OPERATIONAL']
      )
);
```