Select distinct txttif.*, tcttif.* from txttif, tcttif where Txcnt=Tccit and Tctab='txttif' and Tctag=5 and ((Tcdal<='2018-04-22' and Tcall>='2018-04-22') or (Tcall is NULL or Tcall='')) order by Tcall desc, Tcdal desc, Txcnt desc
Select distinct txttif.*, tcttif.* from txttif, tcttif where Txcnt=Tccit and Tctab='txttif' and Tctag=33 and ((Tcdal<='2018-04-22' and Tcall>='2018-04-22') or (Tcall is NULL or Tcall='')) order by Tcall desc, Tcdal desc, Txcnt desc
Select distinct txttif.*, tcttif.* from txttif, tcttif where Txcnt=Tccit and Tctab='txttif' and Tctag=31 and ((Tcdal<='2018-04-22' and Tcall>='2018-04-22') or (Tcall is NULL or Tcall='')) order by Tcall desc, Tcdal desc, Txcnt desc