PromptBase
Upgrade
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
Chat - GPT-3.5 (gpt-3.5-turbo)
Token size
Example input
Question: "Write the SQL query to get the third maximum salary of an employee from a table named employees" Employee table employee_name salary A 24000 C 34000 D 55000 E 75000 F 21000 G 40000 H 50000
Example output
Sure, I can help with that! Here's the SQL query to retrieve the third highest salary from the "employees" table: sql SELECT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET 2; This query first sorts the salaries in descending order using the ORDER BY clause. Then it uses the LIMIT and OFFSET clauses to skip the first two rows (i.e., the two highest salaries) and return the third highest salary. Note that if there are duplicate salaries, this query will return the third highest distinct salary. If you want to include ties, you can use the DENSE_RANK function instead. Here's an example query that uses DENSE_RANK: sql SELECT DISTINCT salary FROM employees WHERE DENSE_RANK() OVER (ORDER BY salary DESC) = 3; This query uses the DENSE_RANK window function to assign a rank to each salary, based on the descending order of salaries. It then filters the result set to include only the rows where the salary has a rank of 3 (i.e., the third highest salary, or the third highest salary in case of ties). The DISTINCT keyword is used to remove duplicates from the result set.
Add to Cart
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
GPT-3.5-TURBO
Tested icon
Free credits icon
Savings iconBlock icon
πŸ”πŸ“Š Need help with SQL? Look no further! πŸ’‘πŸ’» 🎯 Answer SQL-related questions, or output standard SQL statements effortlessly with ChatGPT! πŸš€πŸ”’ ⚑️ Whether you're a beginner or a pro, our AI-powered model is here to simplify your SQL experience. πŸ’ͺ✨ πŸ’¬ Simply ask your SQL question with our prompts, and ChatGPT will provide you with accurate answers and generate standard SQL statements in a snap! πŸ“πŸ’¬ πŸ‘‰ Try ChatGPT now and witness the magic for yourself.
...more
Added over 1 month ago
Report
  • Reviews for this prompt (1)
Browse Marketplace