I am trying to figure out the use of CASE WHEN ELSE END.
I have 1 table (Service) that uses a Foreign Key (FKTypeOfService).
In some cases there is not TypeOfService, and therefore no entry.
I would like to show both possibilities in one Query.
Outcome required:
Service1, FKTypeOfService1
Service2, FKTypeOfService1
Service3, FKTypeOfService2
Service4, .......
........
Servicex
Servicey
Servicez
........
I am trying to use the following principle:
In CASE there is no FKTypeOfService, THEN only show Service, ELSE show Service, FKTypeOfService
The outcome does not make sense to me, so I am doing something wrong, but do not know what.
When using the following SQL:
Code: Select all
SELECT
CASE WHEN "Service"."FKTypeOfServiceID" = NULL THEN "Service"."Service" ELSE "Service"."UnitPrice" END AS "Service"
FROM
"Service",
"TypeOfService"
SQL Status: S1000
Error code: -216
Unresolved parameter type as output of CASE when operand types are VARCHAR and NUMERIC in statement [SELECT CASE WHEN "Service"."FKTypeOfServiceID" = NULL THEN "Service"."Service" ELSE "Service"."UnitPrice" END AS "Service" FROM "Service", "TypeOfService"]
The tables are:
Service
ServiceID Integer [INTEGER] (Primary Key)
FKTypeOfServiceID Integer [INTEGER] (Foreign Key)
Service Text [VARCHAR]
UnitPrice Number [NUMERIC]
TypeOfService
TypeOfServiceID Integer [INTEGER] (Primary Key)
TypeOfService Text [VARCHAR]
Where am I going wrong?
Dream