Skip to content

Commit

Permalink
feat: improve SQL query generation for top/bottom rankings
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Liebmann committed Jan 17, 2025
1 parent aa4a9ff commit 83ad695
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/actions/chatWithYourDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ async function generateSqlQuery(apiKey: string, schemaInfo: string, question: st
* Cast numeric values explicitly (e.g., CAST(value AS NUMERIC))
* Use ROUND(CAST(value AS NUMERIC), 2) for decimal places
* Handle NULL values with COALESCE
- When combining results (top/bottom rankings):
* Use WITH clauses for better readability
* Ensure column names and types match in UNION queries
* Add labels/indicators to distinguish top vs bottom results
* Use row_number() for rankings when needed
- Do not include markdown code blocks or SQL syntax highlighting in your response
- Do not include any other text in your response
- If you cannot construct a query using only the available columns, respond with an error message starting with "ERROR:"`;
Expand Down

0 comments on commit 83ad695

Please sign in to comment.