# ProductDealsByProductId
## Documentation
The deals in which one product is sold. Each request costs 20 tokens of the daily budget of the company.
- Catalog: `Pipedrive`
- Schema: `Products`
- Primary Keys: `id`
This is a read-only table function. The Pipedrive API may not support changing the data or the Invantive UniversalSQL driver for Pipedrive does not cover it. In the latter case, please use the table NativePlatformScalarRequests to upload data to the Pipedrive API.
## Parameters of Table Function
The following parameters can be used to control the behaviour of the table function `ProductDealsByProductId`. A value must be provided at all times for required parameters, but optional parameters in general do not need to have a value and the execution will default to a pre-defined behaviour. Values can be specified by position and by name. In both cases, all parameters not specified will be evaluated using their default values.
Value specification by position is done by listing all values from the first to the last needed value. For example: a `select * from table(value1, value2, value3)` on a table with four parameters will use the default value for the fourth parameter and the specified values for the first three.
Value specification by name is done by listing all values that require a value. For example with `select * from table(name1 => value1, name3 => value3)` on the same table will use the default values for the second and fourth parameters and the specified values for the first and third.
| Name | Data Type | Required | Default Value | Documentation |
|---|:---:|:---:|:---:|---|
| `product_id` | `int64` | ☑ | | The product id. |
## Columns of Table Function
The columns of the table function `ProductDealsByProductId` are shown below. Each column has an SQL data type.
| Name | Data Type | Label | Required | Documentation |
|---|:---:|---|:---:|---|
| `active` | `char` | | ☐ | Whether the deal is active or not. |
| `activities_count` | `int64` | | ☐ | The number of activities associated with the deal. |
| `acv_currency` | `varchar2` | | ☐ | The Currency for Annual Contract Value of the deal. Only on the Growth plan and above. |
| `acv` | `decimal` | | ☐ | The Annual Contract Value of the deal. Only on the Growth plan and above. |
| `add_time` | `datetime` | | ☐ | The creation date and time of the deal. |
| `arr_currency` | `varchar2` | | ☐ | The Currency for Annual Recurring Revenue of the deal. Only on the Growth plan and above. |
| `arr` | `decimal` | | ☐ | The Annual Recurring Revenue of the deal. Only on the Growth plan and above. |
| `cc_email` | `varchar2` | | ☐ | The BCC email of the deal. |
| `channel_id` | `varchar2` | | ☐ | The optional ID to further distinguish the Marketing channel. |
| `channel` | `int64` | | ☐ | The ID of your Marketing channel this Deal was created from. |
| `close_time` | `datetime` | | ☐ | The date and time of closing the deal. |
| `creator_user_id_active_flag` | `char` | | ☐ | Whether the creator is active or not. |
| `creator_user_id_email` | `varchar2` | | ☐ | The email of the deal creator. |
| `creator_user_id_has_pic` | `int64` | | ☐ | If the creator has a picture or not. |
| `creator_user_id_id` | `int64` | | ☐ | The ID of the deal creator. |
| `creator_user_id_name` | `varchar2` | | ☐ | The name of the deal creator. |
| `creator_user_id_pic_hash` | `varchar2` | | ☐ | The creator picture hash. |
| `creator_user_id_value` | `int64` | | ☐ | The ID of the deal creator. |
| `currency` | `varchar2` | | ☐ | The currency associated with the deal. |
| `deleted` | `char` | | ☐ | Whether the deal is deleted or not. |
| `done_activities_count` | `int64` | | ☐ | The number of completed activities associated with the deal. |
| `email_messages_count` | `int64` | | ☐ | The number of emails associated with the deal. |
| `expected_close_date` | `datetime` | | ☐ | The expected close date of the deal. |
| `files_count` | `int64` | | ☐ | The number of files associated with the deal. |
| `first_won_time` | `datetime` | | ☐ | The date and time of the first time changing the deal status as won. |
| `followers_count` | `int64` | | ☐ | The number of followers associated with the deal. |
| `formatted_value` | `varchar2` | | ☐ | The deal value formatted with selected currency. |
| `formatted_weighted_value` | `varchar2` | | ☐ | The weighted_value formatted with selected currency. |
| `id` | `int64` | | ☑ | The ID of the deal. |
| `is_archived` | `char` | | ☐ | Whether the deal is archived or not. |
| `label` | `varchar2` | | ☐ | The label or multiple labels assigned to the deal. |
| `last_activity_date` | `datetime` | | ☐ | The date of the last activity associated with the deal. |
| `last_activity_id` | `int64` | | ☐ | The ID of the last activity associated with the deal. |
| `last_incoming_mail_time` | `datetime` | | ☐ | The date and time of the last incoming email associated with the deal. |
| `last_outgoing_mail_time` | `datetime` | | ☐ | The date and time of the last outgoing email associated with the deal. |
| `lost_reason` | `varchar2` | | ☐ | The reason for losing the deal. |
| `lost_time` | `datetime` | | ☐ | The date and time of changing the deal status as lost. |
| `mrr_currency` | `varchar2` | | ☐ | The Currency for Monthly Recurring Revenue of the deal. Only on the Growth plan and above. |
| `mrr` | `decimal` | | ☐ | The Monthly Recurring Revenue of the deal. Only on the Growth plan and above. |
| `next_activity_date` | `datetime` | | ☐ | The date of the next activity associated with the deal. |
| `next_activity_duration` | `varchar2` | | ☐ | The duration of the next activity associated with the deal. |
| `next_activity_id` | `int64` | | ☐ | The ID of the next activity associated with the deal. |
| `next_activity_note` | `varchar2` | | ☐ | The note of the next activity associated with the deal. |
| `next_activity_subject` | `varchar2` | | ☐ | The subject of the next activity associated with the deal. |
| `next_activity_time` | `datetime` | | ☐ | The time of the next activity associated with the deal. |
| `next_activity_type` | `varchar2` | | ☐ | The type of the next activity associated with the deal. |
| `notes_count` | `int64` | | ☐ | The number of notes associated with the deal. |
| `org_hidden` | `char` | | ☐ | If the organization that is associated with the deal is hidden or not. |
| `org_id_active_flag` | `char` | | ☐ | Whether the associated organization is active or not. |
| `org_id_address` | `varchar2` | | ☐ | The address of the organization that is associated with the deal. |
| `org_id_cc_email` | `varchar2` | | ☐ | The BCC email of the organization associated with the deal. |
| `org_id_name` | `varchar2` | | ☐ | The name of the organization associated with the deal. |
| `org_id_owner_id` | `int64` | | ☐ | The ID of the owner of the organization that is associated with the deal. |
| `org_id_people_count` | `int64` | | ☐ | The number of people connected with the organization that is associated with the deal. |
| `org_id_value` | `int64` | | ☐ | The ID of the organization associated with the deal. |
| `org_name` | `varchar2` | | ☐ | The name of the organization associated with the deal. |
| `origin_id` | `varchar2` | | ☐ | The optional ID to further distinguish the origin of the deal - e.g. Which API integration created this Deal. |
| `origin` | `varchar2` | | ☐ | The way this Deal was created. |
| `owner_name` | `varchar2` | | ☐ | The name of the deal owner. |
| `participants_count` | `int64` | | ☐ | The number of participants associated with the deal. |
| `person_hidden` | `char` | | ☐ | If the person that is associated with the deal is hidden or not. |
| `person_id_active_flag` | `char` | | ☐ | Whether the associated person is active or not. |
| `person_id_email` | `varchar2` | | ☐ | The emails of the person associated with the deal. |
| `person_id_name` | `varchar2` | | ☐ | The name of the person associated with the deal. |
| `person_id_owner_id` | `int64` | | ☐ | The ID of the owner of the person that is associated with the deal. |
| `person_id_phone` | `varchar2` | | ☐ | The phone numbers of the person associated with the deal. |
| `person_id_value` | `int64` | | ☐ | The ID of the person associated with the deal. |
| `person_name` | `varchar2` | | ☐ | The name of the person associated with the deal. |
| `pipeline_id` | `int64` | | ☐ | The ID of the pipeline associated with the deal. |
| `probability` | `decimal` | | ☐ | The success probability percentage of the deal. |
| `product_id` | `int64` | | ☐ | The product id the rows were read for. |
| `products_count` | `int64` | | ☐ | The number of products associated with the deal. |
| `rotten_time` | `datetime` | | ☐ | The date and time of changing the deal status as rotten. |
| `stage_change_time` | `datetime` | | ☐ | The last updated date and time of the deal stage. |
| `stage_id` | `int64` | | ☐ | The ID of the deal stage. |
| `stage_order_nr` | `int64` | | ☐ | The order number of the deal stage associated with the deal. |
| `status` | `varchar2` | | ☐ | The status of the deal. |
| `title` | `varchar2` | | ☐ | The title of the deal. |
| `undone_activities_count` | `int64` | | ☐ | The number of incomplete activities associated with the deal. |
| `update_time` | `datetime` | | ☐ | The last updated date and time of the deal. |
| `user_id_active_flag` | `char` | | ☐ | Whether the user is active or not. |
| `user_id_email` | `varchar2` | | ☐ | The email of the user. |
| `user_id_has_pic` | `char` | | ☐ | If the user has a picture or not. |
| `user_id_id` | `int64` | | ☐ | The ID of the user. |
| `user_id_name` | `varchar2` | | ☐ | The name of the user. |
| `user_id_pic_hash` | `varchar2` | | ☐ | The user picture hash. |
| `user_id_value` | `int64` | | ☐ | The ID of the user. |
| `value` | `decimal` | | ☐ | The value of the deal. |
| `visible_to` | `varchar2` | | ☐ | The visibility of the deal. |
| `weighted_value_currency` | `varchar2` | | ☐ | The currency associated with the deal. |
| `weighted_value` | `decimal` | | ☐ | Probability times deal value. |
| `won_time` | `datetime` | | ☐ | The date and time of changing the deal status as won. |