I have a query that I would like to run using my data visualization tool (Tableau), however when I tried to retrieve records using SQL query based on distinct(id) as shown below data, I am receiving error on "Expected: CASE, CAST, DEFAULT, EXISTS, FALSE, IF, INTERVAL, NOT, NULL, REPLACE, TRUNCATE, TRUE, IDENTIFIER CAUSED BY: Exception: Syntax error"
The data looks somethings like this
tablename | id | records
table_1 3 344
table_2 4 222
table_1 3 344
table_2 4 222
Expected output
tablename | id | record
table_1 3 344
table_2 4 222
This is the query that I used
case when id = distinct(id) then 'distinct value' else 'not required' end
I have also tried distinct(id)
but seems visualization BI is expecting me to use case instead. By any chance I am doing this query wrong?
Your SQL statement is invalid. You can try this-
SELECT table_name, id, MAX(record) FROM table GROUP BY table_name, id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.