Prompt Engineering Guide
Mastering Write SQL query
on Perplexity Online 70B
Stop guessing. See how professional prompt engineering transforms Perplexity Online 70B's output for specific technical tasks.
The "Vibe" Prompt
"Write a SQL query to get the top 5 customers by total order amount this year."
Low specificity, inconsistent output
Optimized Version
Given a database schema with tables `customers` (customer_id, customer_name) and `orders` (order_id, customer_id, order_date, total_amount), write a SQL query to retrieve the names of the top 5 customers who have spent the most in the current year. The query should return `customer_name` and their `total_spent` for the current year. Please ensure the query is highly performant and considers appropriate indexing if applicable (though don't include index creation in the query itself).
Structured, task-focused, reduced hallucinations
Engineering Rationale
The optimized prompt provides crucial context like table names, column names, and their relationships, which are essential for generating an accurate SQL query. It also clarifies the desired output columns and adds constraints like 'current year' and 'highly performant', guiding the model towards a more specific and practical solution. This reduces ambiguity and the need for the model to guess schema details.
0%
Token Efficiency Gain
The optimized query should join 'customers' and 'orders' tables.
The query should filter orders by the current year.
The query should group results by customer_id/customer_name.
Ready to stop burning tokens?
Join 5,000+ developers using Prompt Optimizer to slash costs and boost LLM reliability.
Optimize My Prompts