Date: prev next · Thread: first prev next last
2016 Archives by date, by thread · List index


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: users+unsubscribe@global.libreoffice.org
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

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.