1 (edited by dbk 2018-11-13 21:37:52)

Topic: [SOLVED] Use boolean/calculated field in report

Hello friends,

I have a calculated field in my table which calculates the result of the boolean field in the tablegrid.

case table_field when 1 then 'Yes' when 0 then 'No' else '' end

I have created a dataset to make a report like so

 SQLQuery('SELECT * FROM table WHERE table.id = '+form1.Edit10.Text , Results1);

This does not include the calculcated field in the dataset.

My question, how can i include the calculated field, or replicate it, for use in the report? So, if boolean = 1 i want to show 'Yes' in the report.

Kind regards

Re: [SOLVED] Use boolean/calculated field in report

CASE WHEN (strftime('%s', 'now') - strftime('%s', ping)) < 12 THEN 'Yes' ELSE 'No' END  

SQLExecute ('UPDATE users SET ping = datetime(''now'') WHERE id='+IntToStr(idUser));

Re: [SOLVED] Use boolean/calculated field in report

SQLQuery('SELECT fieldname1, fieldname2, (case table_field when 1 then 'Yes' when 0 then 'No' else '' end) as calc_field FROM table WHERE table.id = '+form1.Edit10.Text , Results1);
Dmitry.

Re: [SOLVED] Use boolean/calculated field in report

DriveSoft wrote:
SQLQuery('SELECT fieldname1, fieldname2, (case table_field when 1 then 'Yes' when 0 then 'No' else '' end) as calc_field FROM table WHERE table.id = '+form1.Edit10.Text , Results1);

hello DriveSoft,

thank you, but i get a syntax error, ')' expected

Re: [SOLVED] Use boolean/calculated field in report

Sorry, corrected

SQLQuery('SELECT fieldname1, fieldname2, (case table_field when 1 then ''Yes'' when 0 then ''No'' else '''' end) as calc_field FROM table WHERE table.id = '+form1.Edit10.Text , Results1);
Dmitry.

Re: [SOLVED] Use boolean/calculated field in report

DriveSoft wrote:

Sorry, corrected

SQLQuery('SELECT fieldname1, fieldname2, (case table_field when 1 then ''Yes'' when 0 then ''No'' else '''' end) as calc_field FROM table WHERE table.id = '+form1.Edit10.Text , Results1);

It works!!
Thank you very much Dmitry!!