![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi all. Below is a complex query generated by a persistence system, and the relevant tables. This SQL is too complex for my skills, and it gets this failure: ORDER BY items must appear in the select list if SELECT DISTINCT is specified. Is anyone good enough at SQL to see the obvious problem/fix? I can't even understand the idea that the order-by clause has a select... I tried adding t0.id to the order by, but no difference! thanks in advance! Joe Weinstein at BEA Systems CREATE TABLE PersistentMapHolder_testPCKeyStringValue (PERSISTENTMAPHOLDER_ID BIGINT, value VARCHAR(255), testPCKeyStringValue BIGINT) CREATE TABLE PersistentMapHolder (id BIGINT NOT NULL, PRIMARY KEY (id)) SELECT DISTINCT t0.id, ( SELECT PersistentMapHolder_testPCKeyStringValue.value FROM PersistentMapHolder_testPCKeyStringValue WHERE PersistentMapHolder_testPCKeyStringValue.PERSISTEN TMAPHOLDER_ID = t0.id AND PersistentMapHolder_testPCKeyStringValue.testPCKey StringValue = 53) FROM PersistentMapHolder t0 INNER JOIN PersistentMapHolder_testPCKeyStringValue t1 ON t0.id = t1.PERSISTENTMAPHOLDER_ID WHERE (( SELECT PersistentMapHolder_testPCKeyStringValue.value FROM PersistentMapHolder_testPCKeyStringValue WHERE PersistentMapHolder_testPCKeyStringValue.PERSISTEN TMAPHOLDER_ID = t0.id AND PersistentMapHolder_testPCKeyStringValue.testPCKey StringValue = 53) IS NOT NULL) ORDER BY ( SELECT PersistentMapHolder_testPCKeyStringValue.value FROM PersistentMapHolder_testPCKeyStringValue WHERE PersistentMapHolder_testPCKeyStringValue.PERSISTEN TMAPHOLDER_ID = t0.id AND PersistentMapHolder_testPCKeyStringValue.testPCKey StringValue = 53 ) DESC |
#4
| |||
| |||
|
|
Below is a complex query generated by a persistence system, and the relevant tables. This SQL is too complex for my skills, and it gets this failure: ORDER BY items must appear in the select list if SELECT DISTINCT is specified. Is anyone good enough at SQL to see the obvious problem/fix? I can't even understand the idea that the order-by clause has a select... I tried adding t0.id to the order by, but no difference! thanks in advance! Joe Weinstein at BEA Systems CREATE TABLE PersistentMapHolder_testPCKeyStringValue (PERSISTENTMAPHOLDER_ID BIGINT, value VARCHAR(255), testPCKeyStringValue BIGINT) CREATE TABLE PersistentMapHolder (id BIGINT NOT NULL, PRIMARY KEY (id)) SELECT DISTINCT t0.id, ( SELECT PersistentMapHolder_testPCKeyStringValue.value FROM PersistentMapHolder_testPCKeyStringValue WHERE PersistentMapHolder_testPCKeyStringValue.PERSISTEN TMAPHOLDER_ID = t0.id AND PersistentMapHolder_testPCKeyStringValue.testPCKey StringValue = 53) FROM PersistentMapHolder t0 INNER JOIN PersistentMapHolder_testPCKeyStringValue t1 ON t0.id = t1.PERSISTENTMAPHOLDER_ID WHERE (( SELECT PersistentMapHolder_testPCKeyStringValue.value FROM PersistentMapHolder_testPCKeyStringValue WHERE PersistentMapHolder_testPCKeyStringValue.PERSISTEN TMAPHOLDER_ID = t0.id AND PersistentMapHolder_testPCKeyStringValue.testPCKey StringValue = 53) IS NOT NULL) ORDER BY ( SELECT PersistentMapHolder_testPCKeyStringValue.value FROM PersistentMapHolder_testPCKeyStringValue WHERE PersistentMapHolder_testPCKeyStringValue.PERSISTEN TMAPHOLDER_ID = t0.id AND PersistentMapHolder_testPCKeyStringValue.testPCKey StringValue = 53 ) DESC |
![]() |
| Thread Tools | |
| Display Modes | |
| |