On 11/10/16 10:29 AM, Robert Großkopf wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Gary,

SELECT "event_name", "first_name", "middle_initial", "last_name",
"sex", "age", "email", "place", CASE WHEN "age" BETWEEN 0 AND 18
THEN 'Youth' WHEN "age" BETWEEN 19 AND 59 THEN 'Adult' ELSE
'Senior' END "Group", CASE WHEN "place" <= 3 THEN ( SELECT
"finish", "ribbon" FROM "Ribbons" WHERE "ID" = "place" ) WHEN
"place" >= 4 THEN ( SELECT "finish", "ribbon" FROM "Ribbons" WHERE
"ID" = "4" ) END "Finish", "Ribbon" FROM "Results"
1. A subselect must have only one row with one field.
2. If you want to connect a subselsect with the outer select, you have
to write a correlative select.

SELECT "event_name", "first_name", "middle_initial", "last_name",
"sex", "age", "email", "place",
CASE
     WHEN "age" BETWEEN 0 AND 18  THEN 'Youth'
     WHEN "age" BETWEEN 19 AND 59 THEN 'Adult'
     ELSE 'Senior'
END "Group",
CASE
    WHEN "place" <= 3 THEN ( SELECT "finish" FROM "Ribbons"
       WHERE "ID" = "a"."place" )
    WHEN "place" >= 4 THEN ( SELECT "finish" FROM "Ribbons"
    WHERE "ID" = "4" )
END "Finish",
CASE
    WHEN "place" <= 3 THEN ( SELECT "ribbon" FROM "Ribbons"
       WHERE "ID" = "a"."place" )
    WHEN "place" >= 4 THEN ( SELECT "ribbon" FROM "Ribbons"
       WHERE "ID" = "4" )
END "Ribbon"
FROM "Results" AS "a"

With "a"."place" the subselscts reads the value of "place" from the
current row, which is read out from "Results".

Sounds good in theory but I get the same error. I've also tried it with just sub-selecting for just one field (remove the last CASE statement) and again get the same error.

--
To unsubscribe e-mail to: [email protected]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Reply via email to