Table: salesforce_opportunity - Query Salesforce Opportunities using SQL
Salesforce Opportunity is a component of Salesforce Sales Cloud that allows businesses to manage their sales cycles and deals. It provides a way to track and measure potential revenue, and monitor sales stages, from prospecting to closing. Salesforce Opportunity is instrumental in understanding a company's sales pipeline and forecasting sales.
Table Usage Guide
The salesforce_opportunity
table provides insights into Opportunities within Salesforce Sales Cloud. As a sales manager or data analyst, explore opportunity-specific details through this table, including deal value, expected close date, and associated account details. Utilize it to uncover information about sales performance, such as deals in the pipeline, the value of potential revenue, and the progress of deals through sales stages.
Important Notes
- If the
naming_convention
configuration argument is set toapi_native
, please see API Native Examples.
Examples
Basic info
Gain insights into your sales opportunities by sorting them based on their stage in the sales process. This helps prioritize opportunities that are closer to closing, improving sales efficiency and forecasting.
select id, name, amount, type, stage_name, forecast_category, is_wonfrom salesforce_opportunityorder by stage_name;
select id, name, amount, type, stage_name, forecast_category, is_wonfrom salesforce_opportunityorder by stage_name;
List only won opportunities
Explore which sales opportunities have been successful to understand the areas of high revenue generation. This can help in strategizing future sales approaches.
select id, name, amount, type, is_wonfrom salesforce_opportunitywhere is_wonorder by amount;
select id, name, amount, type, is_wonfrom salesforce_opportunitywhere is_wonorder by amount;
List number of opportunities with respective stage
Determine the distribution of sales opportunities across different stages. This can help you understand where most of your opportunities are concentrated, allowing you to strategize and allocate resources effectively.
select count(*), stage_namefrom salesforce_opportunitygroup by stage_name;
select count(*), stage_namefrom salesforce_opportunitygroup by stage_name;
API Native Examples
If the naming_convention
config argument is set to api_native
, the table and column names will match Salesforce naming conventions.
Basic info (with API Native naming convention)
Explore the opportunities in your pipeline, focusing on their names, amounts, types, and forecast categories, to gain insights into their stages. This is useful for understanding the distribution and potential value of your opportunities, which can inform your sales strategy and prioritization.
select "ID", "Name", "Amount", "Type", "StageName", "ForecastCategory"from "Opportunity"order by "StageName";
select "ID", "Name", "Amount", "Type", "StageName", "ForecastCategory"from "Opportunity"order by "StageName";
List only won opportunities (with API Native naming convention)
Discover the segments that have been successful by identifying instances where opportunities have been won. This can help assess the elements within these successful opportunities to strategize for future prospects.
select "ID", "Name", "Amount", "Type", "StageName", "ForecastCategory", "IsWon"from "Opportunity"where "IsWon"order by "Amount";
select "ID", "Name", "Amount", "Type", "StageName", "ForecastCategory", "IsWon"from "Opportunity"where "IsWon"order by "Amount";
List closed opportunities
Explore which business opportunities have already reached their close date. This can help in assessing past performance and strategizing for future opportunities.
select "ID", "Name", "Amount", "Type", "StageName", "ForecastCategory"from "Opportunity"where "CloseDate" <= now();
select "ID", "Name", "Amount", "Type", "StageName", "ForecastCategory"from "Opportunity"where "CloseDate" <= datetime('now');
List opportunities with open activity
Explore which opportunities have an open activity to determine areas for potential business growth. This can help in identifying instances where immediate action is required, aiding in effective decision making.
select "ID", "Name", "Amount", "Type", "StageName", "ForecastCategory"from "Opportunity"where "HasOpenActivity";
select "ID", "Name", "Amount", "Type", "StageName", "ForecastCategory"from "Opportunity"where "HasOpenActivity";
Schema for salesforce_opportunity
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | ID of the account associated with this opportunity. | |
amount | double precision | Estimated total sale amount. For opportunities with products, the amount is the sum of the related products. | |
campaign_id | text | ID of a related Campaign. This field is defined only for those organizations that have the campaign feature Campaigns enabled. | |
close_date | timestamp with time zone | Date when the opportunity is expected to close. | |
created_by_id | text | Id of the user who created the opportunity. | |
created_date | timestamp with time zone | The creation date and time of the opportunity. | |
description | text | Description of the opportunity. | |
expected_revenue | double precision | Calculated revenue based on the Amount and Probability fields. | |
fiscal_quarter | bigint | Represents the fiscal quarter. Valid values are 1, 2, 3, or 4. | |
fiscal_year | bigint | Represents the fiscal year, for example, 2006. | |
forecast_category | text | Forecast category name displayed in reports, opportunity detail and edit pages, opportunity searches, and opportunity list views. | |
forecast_category_name | text | Name of the forecast category. | |
has_open_activity | boolean | Indicates whether an opportunity has an open event or task (true) or not (false). | |
has_opportunity_line_item | boolean | Indicates whether the opportunity has associated line items. A value of true means that Opportunity line items have been created for the opportunity. | |
has_overdue_task | boolean | Indicates whether an opportunity has an overdue task (true) or not (false). | |
id | text | Unique identifier of the opportunity in Salesforce. | |
is_closed | boolean | Indicates that the opportunity is closed. | |
is_deleted | boolean | Indicates that the opportunity is deleted. | |
is_private | boolean | Indicates that the opportunity is private. | |
is_won | boolean | Indicates that the quote or proposal has been signed or electronically accepted. | |
last_activity_date | timestamp with time zone | Value is one of the following, whichever is the most recent of a) Due date of the most recent event logged against the record or b) Due date of the most recently closed task associated with the record. | |
last_modified_by_id | text | The id of the user who last modified the oppurtinity record. | |
last_modified_date | timestamp with time zone | The data and time of the last modification of the oppurtinity record. | |
lead_source | text | Source of this opportunity, such as Advertisement or Trade Show. | |
name | text | A name for this opportunity. | |
next_step | text | Description of next task in closing opportunity. | |
owner_id | text | ID of the User who has been assigned to work this opportunity. | |
pricebook_2_id | text | ID of a related Pricebook2 object. The Pricebook2Id field indicates which Pricebook2 applies to this opportunity. The Pricebook2Id field is defined only for those organizations that have products enabled as a feature. | |
probability | double precision | Percentage of estimated confidence in closing the opportunity. | |
sp_connection_name | text | Steampipe connection name. | |
sp_ctx | jsonb | Steampipe context in JSON form. | |
stage_name | text | Current stage of opportunity. | |
system_modstamp | text | The date and time when opportunity was last modified by a user or by an automated process. | |
total_opportunity_quantity | text | Number of items included in this opportunity. Used in quantity-based forecasting. | |
type | text | Type of opportunity, such as Existing Business or New Business. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- salesforce
You can pass the configuration to the command with the --config
argument:
steampipe_export_salesforce --config '<your_config>' salesforce_opportunity