SQL to create a boolean column for either column 1 or column 2 is true

NT100

Registered User.
Local time
Today, 22:41
Joined
Jul 29, 2017
Messages
148
I have a tblTutor(Key: TRef) and tblTAvail(foreign key: TRef) tables.
tblTutor: TRef(key), FHKAM_FM(boolean type) FHKCFP(boolean type)
tblTAvail: TRef(foreign key), SessionNumber

I need to make a SQL to link the tables and list their columns and a boolean column, say "fellow" column (type boolean), which indicates either FHKAM_FM or FHKCFP is true.

Would you suggest for the SQL
 
What have you tried?

Perhaps something like:
Code:
SELECT
  t.TRef,
  a.SessionNumber,
  t.FHKAM_FM,
  t.FHKCFP,
  t.FHKAM_FM OR t.FHKCFP AS AtLeastOneIsTrue
FROM tblTutor t
INNER JOIN tblTAvail a
        ON t.TRef = a.TRef
ORDER BY 
  t.TRef,
  a.SessionNumber
;

hth,

d
 
on your new column:

Expr: switch(FHKAM_FM=true, [fieldtodisplay], FHKCFP=true, [fieldtodisplay], true, "")
 
I have no idea on this. Your suggestion works for my situation. Thank you
 
@NT100, which version worked for you? The query, or arnelgp's expression?

@arnelgp, I'm not sure I understand your expression fully. I'd imagine it should be more like:
Code:
[fieldtodisplay]: Switch(FHKAM_FM=True, True, FHKCFP=True, True, True, "")
but perhaps (quite likely) I have misunderstood the requirement.

:confused:

d
 
on your new column:

Expr: switch(FHKAM_FM=true, [fieldtodisplay], FHKCFP=true, [fieldtodisplay], true, "")

Thank you for the suggestion. I need to study it. It's a good inspiration.
 

Users who are viewing this thread

Back
Top Bottom