• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Get an error when using DISTINCT in SELECT Statement

Resolved: Get an error when using DISTINCT in SELECT Statement

0
By Isaac Tonny on 04/04/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve Get an error when using DISTINCT in SELECT Statement

Question:

I have this query:
and I get this error:

ParseException: Syntax error in line 605:undefined: DISTINCT fact.order_id AS ORDER_ID ^ Encountered: DISTINCT Expected: CASE, CAST, DEFAULT, EXISTS, FALSE, IF, INTERVAL, LEFT, NOT, NULL, REPLACE, RIGHT, TRUNCATE, TRUE, IDENTIFIER CAUSED BY: Exception: Syntax error


I need the ORDER_ID only once, although it can exist multiple times in the table FACT, because I need to count it afterwards.
Thanks for the help.

Best Answer:

DISTINCT considers all the columns in the SELECT statement, not just the specified column; and so the error. So, to filter DISTINCT order_id; you can use group by ORDER_ID :

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

impala sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to stop a thread that has a blocking function from easygui in python

05/04/2023

Resolved: Removing null keys from a json array of objects

05/04/2023

Resolved: How can I generate at compile-time a separate OpenAPI Swagger.json file for each Controller in my ASP.NET project?

05/04/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.