SQL 쿼리 생성

지난달의 고유 로그인을 집계하고 정렬하는 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