How to union in SUITEQL?

388 Views Asked by At

I'm trying to union two queries together. I've copy and pasted this from the advanced queries section of the documentation but keep getting a 500 error (shown below).

SELECT TOP 1 id FROM transaction UNION SELECT TOP 1 id FROM transaction

Why doesn't this query work?


{ "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1", "title": "Internal Server Error", "status": 500, "o:errorDetails": [ { "detail": "An unexpected error occurred. Error ID: ld3pklv4n4wk140q60is", "o:errorCode": "UNEXPECTED_ERROR" } ] }

1

There are 1 best solutions below

0
On

For an unknown reason the solution is to wrap the union in parentheses.

SELECT * FROM (
     SELECT TOP 1 id FROM transaction
     UNION ALL
     SELECT TOP 1 id FROM transaction
)

CREDIT: I found an example buried on an archived slack thread:

Screencapture of the archived site