Case used in SQL Query Any Sugestios?

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
fanton
Posts: 3
Joined: 2022-01-20 16:37

Case used in SQL Query Any Sugestios?

Post by fanton » 2023-07-22 08:06

Field VarChar= `Reg_Determinari`.`RH_D - OPTION LIST (Pozitiv;;Negativ;;Incert;;_______;;D Slab)
Field VarChar= `Reg_Determinari`.`D`

Query:

SELECT `Reg_Determinari`.`RH_D`, `Reg_Determinari`.`D`
CASE
WHEN`Reg_Determinari`.`RH_D` = 'Pozitiv' THEN 'D'
WHEN`Reg_Determinari`.`RH_D` = 'Negativ' THEN 'd'
WHEN`Reg_Determinari`.`RH_D` = 'Incert' THEN 'D(incert)'
WHEN`Reg_Determinari`.`RH_D` = 'D Slab' THEN 'D(Slab)'
WHEN`Reg_Determinari`.`RH_D` = '_______' THEN ''
END AS `Reg_Determinari`.`D`

FROM `Reg_Determinari`
WHERE `Reg_Determinari`.`ID`='%ID%'


User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Case used in SQL Query Any Sugestios?

Post by jsetzer » 2023-07-31 10:46

I agree with Olaf: your question is not very clear. I guess you have problems with SQL for a calculated field, right?

SQL query for calculated field should return exactly one value.

Code: Select all

SELECT CASE
WHEN`Reg_Determinari`.`RH_D` = 'Pozitiv' THEN 'D'
WHEN`Reg_Determinari`.`RH_D` = 'Negativ' THEN 'd'
WHEN`Reg_Determinari`.`RH_D` = 'Incert' THEN 'D(incert)'
WHEN`Reg_Determinari`.`RH_D` = 'D Slab' THEN 'D(Slab)'
WHEN`Reg_Determinari`.`RH_D` = '_______' THEN ''
END FROM `Reg_Determinari`
WHERE `Reg_Determinari`.`ID`='%ID%'
PS: please always put code in [code]...[/code]-tags for better readability.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

Post Reply