[ 
https://issues.apache.org/jira/browse/DERBY-7051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16906182#comment-16906182
 ] 

Rick Hillegas commented on DERBY-7051:
--------------------------------------

That is non-Standard syntax. The <set quantifier> (DISTINCT) must appear before 
the entire <select list> according to the 2016 SQL Standard, part 2, subclause 
7.16 (<query specification>). You cannot use the DISTINCT quantifier to 
decorate individual items in the <select list>.

I'm not sure what you are trying to achieve with that query. Maybe the 
following workaround will help:

{noformat}
connect 'jdbc:derby:memory:db;create=true';

CREATE TABLE orders (customerID BIGINT, orderID BIGINT);

-- illegal syntax
SELECT DISTINCT(customerID), DISTINCT(orderID) FROM orders;

-- works
SELECT DISTINCT customerID, orderID FROM orders;
{noformat}


> Multiple DISTINCT columns are not supported
> -------------------------------------------
>
>                 Key: DERBY-7051
>                 URL: https://issues.apache.org/jira/browse/DERBY-7051
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>         Environment: derby-10.11.1.1;
>            Reporter: JackLi0812
>            Priority: Major
>
>  
> {code:java}
> SELECT DISTINCT (ORDERS.CUSTOMER_ID), DISTINCT (ORDERS.ORDER_ID)
> FROM ORDERS
> ORDER BY ORDERS.ORDER_ID
> ;{code}
> throw error: 
> {code:java}
> SQL Error [42X01]: Syntax error: Encountered "DISTINCT" at line 1, column 39.
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to