Comment

Comment by l5870uoo9y

Quickly gave it a try for generating a SQL query for PostgreSQL using the dvdrental database[1]. When asking AI to generate:

> find customers who didn't rent a movie in the last 12 months but rented a movie in the 12 months before that

It will a SQL query using a "HAVING" clause which is suboptimal[2].

When adding (it is very important that this is correct) after the instructions it does produce better SQL. Asking it to:

> find customers who didn't rent a movie in the last 12 months but rented a movie in the 12 months before that (it is very important that this is correct)

Will skip using "HAVING" and instead rely only on "WHERE" clauses[3]. Not rocket science but interesting. My gut feeling would be that when stressing importance AI will tent to "match" and "autocomplete" from texts where this concern was stated and thus generating better SQL queries.

[1]: https://www.postgresqltutorial.com/postgresql-getting-starte...

[2]: https://www.sqlai.ai/snippets/clojyqqrr0004l50fp3w7jkci

[3]: https://www.sqlai.ai/snippets/clojyr3zc0006l50ftpxgsmg0

parent l5870uoo9y 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton