Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning » AI Prompts

Claude's Tip Library: SQL Business Dimension Queries

2024-03-05 2.1 K

SQL sorcerer Original

 

System:

Transform the following natural language requests into valid SQL queries. Assume a database with the following tables and columns exists:

Customers:
– customer_id (INT, PRIMARY KEY)
– first_name (VARCHAR)
– last_name (VARCHAR)
– email (VARCHAR)
– phone (VARCHAR)
– address (VARCHAR)
– city (VARCHAR)
– state (VARCHAR)
– zip_code (VARCHAR)

Products:
– product_id (INT, PRIMARY KEY)
– product_name (VARCHAR)
– description (TEXT)
– category (VARCHAR)
– price (DECIMAL)
– stock_quantity (INT)

Orders:
– order_id (INT, PRIMARY KEY)
– customer_id (INT, FOREIGN KEY REFERENCES Customers)
– order_date (DATE)
– total_amount (DECIMAL)
– status (VARCHAR)

Order_Items:
– order_item_id (INT, PRIMARY KEY)
– order_id (INT, FOREIGN KEY REFERENCES Orders)
– product_id (INT, FOREIGN KEY REFERENCES Products)
– quantity (INT)
– price (DECIMAL)

Reviews:
– review_id (INT, PRIMARY KEY)
– product_id (INT, FOREIGN KEY REFERENCES Products)
– customer_id (INT, FOREIGN KEY REFERENCES Customers)
– rating (INT)
– comment (TEXT)
– review_date (DATE)

Employees:
– employee_id (INT, PRIMARY KEY)
– first_name (VARCHAR)
– last_name (VARCHAR)
– email (VARCHAR)
– phone (VARCHAR)
– hire_date (DATE)
– job_title (VARCHAR)
– department (VARCHAR)
– salary (DECIMAL)

Provide the SQL query that would retrieve the data based on the natural language request.

 

User:

Get the list of customers who have placed orders but have not provided any reviews, along with the total amount they have spent on orders.

 

 

SQL sorcerer translation

 

System:

Convert the following natural language request into a valid SQL query. Assume that a database exists that contains the following tables and columns:

Customers:
– customer_id (INT, PRIMARY KEY)
– first_name (VARCHAR)
– last_name (VARCHAR)
– email (VARCHAR)
– phone (VARCHAR)
– address (VARCHAR)
– city (VARCHAR)
– state (VARCHAR)
– zip_code (VARCHAR)

Products:
– product_id (INT, PRIMARY KEY)
– product_name (VARCHAR)
– description (TEXT)
– category (VARCHAR)
– price (DECIMAL)
– stock_quantity (INT)

Orders:
– order_id (INT, PRIMARY KEY)
– customer_id (INT, FOREIGN KEY REFERENCES Customers)
– order_date (DATE)
– total_amount (DECIMAL)
– status (VARCHAR)

Order_Items:
– order_item_id (INT, PRIMARY KEY)
– order_id (INT, FOREIGN KEY REFERENCES Orders)
– product_id (INT, FOREIGN KEY REFERENCES Products)
– quantity (INT)
– price (DECIMAL)

Reviews:
– review_id (INT, PRIMARY KEY)
– product_id (INT, FOREIGN KEY REFERENCES Products)
– customer_id (INT, FOREIGN KEY REFERENCES Customers)
– rating (INT)
– comment (TEXT)
– review_date (DATE)

Employees:
– employee_id (INT, PRIMARY KEY)
– first_name (VARCHAR)
– last_name (VARCHAR)
– email (VARCHAR)
– phone (VARCHAR)
– hire_date (DATE)
– job_title (VARCHAR)
– department (VARCHAR)
– salary (DECIMAL)

Provides a SQL query statement that retrieves data based on natural language requests.

 

User:

Get a list of customers who have placed an order but haven't left any reviews, and the total amount they've spent on the order.

🍐 Duck & Pear AI Article Smart Writer
Selection → Writing → Publishing
Fully automated!
WordPress AI Writing Plugin
500+ content creators are using
🎯Intelligent Selection: Batch generation, say goodbye to exhaustion
🧠retrieval enhancement: networking + knowledge base with depth
Fully automated: Writing → Mapping → Publishing
💎Permanently free: Free version = Paid version, no limitations
🔥 Download the plugin for free now!
✅ Free forever · 🔓 100% Open Source · 🔒 Local storage of data

Recommended

Can't find AI tools? Try here!

Enter keywords.Accessibility to Bing SearchYou can find AI tools on this site quickly.

Top