How to get the constant answer for the same prompt while converting natural language to SQL query

When I try to convert the natural language to SQL query , I am getting different queries for the same prompt.How to avoid this issue?

1)If I ask How many customers logged in today ?the model send a response as
SELECT COUNT(*)
FROM usage.Fact_DailyLogins
WHERE Date = GETDATE()"
If I execute this query , it has returned 0.
2)If I ask ,mention the customers who have logged in today?the model response as
“SELECT c.Name
FROM dbo.Customer c
JOIN usage.Fact_DailyLogins dl ON c.Id = dl.CustomerId
WHERE dl.Date = CAST(GETDATE() AS DATE)”
If I execute this query It has returned nine customers.

Table structure:
CustomerId - Unique Id for each customers
userId -Unique Id for each users
Date - Login data
Count - Number of times logged-in per day

llm #CONVERTING NATURAL LANGUAGE TO SQL QUERY #SQL QUERY GENERATOR

Which model are you using? GPT-3.5 or 4? If it’s 3.5 I would for sure try GPT-4 as this is far more in it’s ability range.

1 Like