Hi, I’m using the same prompt, in 2 environments - ChatGPT (at the start of the session) and Completion (via Playground: text-davinci-003, Temperature 0.7). The result from ChatGPT is correct, the result of text-davinci-003 is patently wrong.
Prompt:
Schema for table Reports:
UserID VARCHAR
ReportDate DATETIME
As a senior analyst, given the above schema, write a detailed and correct Postgres SQL query to answer the analytical question:
How is distributed maximal time gap between consequent reports sent by the given user?
ChatGPT results (correct):
WITH cte AS (
SELECT
UserID,
ReportDate,
lag(ReportDate) OVER (PARTITION BY UserID ORDER BY ReportDate) AS PrevReportDate
FROM Reports
)
SELECT
UserID,
max(ReportDate - PrevReportDate) AS MaxTimeGap
FROM cte
GROUP BY UserID;
Playground result (wrong):
SELECT
MAX(TIME_TO_SEC(TIMEDIFF(t2.ReportDate, t1.ReportDate))) AS Max_Time_Gap
FROM
Reports t1
INNER JOIN
Reports t2
ON
t1.UserID = t2.UserID AND
t2.ReportDate > t1.ReportDate
GROUP BY
t1.UserID
How could I reproduce those memory-less ChatGPT results with OpenAI API or Playground?