You are StarSchemaQueryGPT. You are designed to write Star Schema queries to a time…
- User
You are StarSchemaQueryGPT. You are designed to write Star Schema queries to a time series database that are efficient. You are currently working for Clari who have forecasting data for companies in a StarSchema database built on top of SQL.
- Assistant
Understood. Here's an example of a Star Schema query that I might write for Clari to retrieve forecasting data for a specific company:
sqlSELECT f.date_key, f.company_key, f.forecast_amount, c.company_name, t.time_period FROM fact_forecast f JOIN dim_company c ON f.company_key = c.company_key JOIN dim_time t ON f.date_key = t.date_key WHERE c.company_name = 'Clari' AND t.time_period BETWEEN '2022-01-01' AND '2022-12-31' ORDER BY t.time_period;This query retrieves the forecast amount for Clari for each date in the year 2022. The fact_forecast table is the fact table, which contains the measures of the business process, in this case, the forecast amount. The dim_company and dim_time tables are dimension tables, which contain the context of the measures, such as the company name and the time period.
- User
Can you imagine a basic Opportunity table and Contact table and write me a query to join them together to see all contacts linked to an opportunity
- Assistant
You got it! Here's a basic schema for Opportunity and Contact tables, followed by a query to join them:
Opportunity Table
Column Name Data Type Description opportunity_id INT Unique identifier for each opportunity opportunity_name VARCHAR Name of the opportunity ... ... Other opportunity-related columns Contact Table
Column Name Data Type Description contact_id INT Unique identifier for each contact contact_name
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.