Subject | UNION - ORDER BY |
---|---|
Author | Andre Dostal |
Post date | 2005-12-21T10:03:02Z |
Hi,
I've a sql statement that works fine on Oracle, but firebird reports an
error:
Dynamic SQL Error
SQL error code = -104
Invalid command
invalid ORDER BY clause
SELECT ID, 0 AS PARENT_ID, NAME, CONTACT_ID,
(SELECT MAX(CONTACT)
FROM T_CONTACT CON
WHERE CON.ID = CC.CONTACT_ID) AS CONTACT, TEXT,
(SELECT COUNT(*)
FROM T_COSTCENTER_LINKS CCL
WHERE CCL.CC_ID = CC.ID) AS CCLCOUNT
FROM T_COSTCENTER CC
WHERE( CCSCHEMA_ID = 1)AND( PARENT_ID IS NULL )
UNION
SELECT ID, PARENT_ID, NAME, CONTACT_ID,
(SELECT MAX(CONTACT)
FROM T_CONTACT CON
WHERE CON.ID = CC.CONTACT_ID) AS CONTACT, TEXT,
(SELECT COUNT(*)
FROM T_COSTCENTER_LINKS CCL WHERE CCL.CC_ID = CC.ID) AS CCLCOUNT
FROM T_COSTCENTER CC
WHERE( CCSCHEMA_ID = 1)AND( PARENT_ID IS NOT NULL )
ORDER BY PARENT_ID, NAME
The statement doesn't work IBConsole, neither within a Delphi programm
Is there a wrong syntax?
Best regards / liebe Grüße aus einem kalten Wien
Andre Dostal
I've a sql statement that works fine on Oracle, but firebird reports an
error:
Dynamic SQL Error
SQL error code = -104
Invalid command
invalid ORDER BY clause
SELECT ID, 0 AS PARENT_ID, NAME, CONTACT_ID,
(SELECT MAX(CONTACT)
FROM T_CONTACT CON
WHERE CON.ID = CC.CONTACT_ID) AS CONTACT, TEXT,
(SELECT COUNT(*)
FROM T_COSTCENTER_LINKS CCL
WHERE CCL.CC_ID = CC.ID) AS CCLCOUNT
FROM T_COSTCENTER CC
WHERE( CCSCHEMA_ID = 1)AND( PARENT_ID IS NULL )
UNION
SELECT ID, PARENT_ID, NAME, CONTACT_ID,
(SELECT MAX(CONTACT)
FROM T_CONTACT CON
WHERE CON.ID = CC.CONTACT_ID) AS CONTACT, TEXT,
(SELECT COUNT(*)
FROM T_COSTCENTER_LINKS CCL WHERE CCL.CC_ID = CC.ID) AS CCLCOUNT
FROM T_COSTCENTER CC
WHERE( CCSCHEMA_ID = 1)AND( PARENT_ID IS NOT NULL )
ORDER BY PARENT_ID, NAME
The statement doesn't work IBConsole, neither within a Delphi programm
Is there a wrong syntax?
Best regards / liebe Grüße aus einem kalten Wien
Andre Dostal