SQL クエリを生成する

過去 1 か月のユニーク ログインのカウントと並べ替えを行う SQL クエリを生成する

直接モデルにクエリを実行して、返された結果をテストできます。その場合、Cloud コンソールでさまざまなパラメータ値を使用することも、Vertex AI API を直接呼び出すこともできます。

自由形式のプロンプト


"Consider a table with schema as described below.
' Column name - Description
' Username - username of the user logging in
' LicenseType - Either ""MultiUse"" or ""SingleUse""
' LoginTime - The datetime of the login event

As data analysis expert, please write a SQL query to show me the list of
users, their license types and the number of unique days on which the user
logged in for the last 3 calendar months. Sort it by highest count of logins
in a month to the lowest count of logins in a month."

                

レスポンス


```sql
WITH MonthlyLogins AS (
SELECT
Username,
LicenseType,
DATE(LoginTime) AS LoginDate
FROM
YourTable
WHERE
LoginTime BETWEEN DATE('now', '-3 months') AND DATE('now')
),
UniqueLoginDays AS (
SELECT
Username,
LicenseType,
COUNT(DISTINCT LoginDate) AS UniqueLoginDays
FROM
MonthlyLogins
GROUP BY
Username,
LicenseType
)
SELECT
Username,
LicenseType,
UniqueLoginDays
FROM
UniqueLoginDays
ORDER BY
UniqueLoginDays DESC;
```

              
モデル: gemini-1.0-pro-001
温度: 0.2
最大出力トークン: 2048
トップ K 40
トップ P 0.95