Sunday, December 1, 2019

orm relation

ELECT a.matr
      ,[nom]
      ,[prn]
      ,cast([dat_nais] as date) as dat_nais
  , (YEAR(getdate()) - YEAR(dat_nais)) as age
      ,cast([dat_deces] as date) as dat_deces
      ,cast([dat_imm] as date) as dat_imm
      ,cast([dat_aj] as date) as dat_j
      ,[cod_position]
  ,YEAR(dat_imm) as anne_imm
  ,YEAR(dat_encais) as ann_regl
      ,[annee]
      ,[cod_nat]
      ,cast([dat_e

Snc] as date) as dat_regl
      ,[mt_encais]
  FROM users a
left join enca e on e.matr = a.matr
left join encr c on (c.cod_encais = e.cod_encais)
  where (YEAR(c.dat_enc) - c.annee > 3 ) and ((YEAR(getdate()) - YEAR(a.dat_nais)) between 54 and 70) and c.cod_nat = 'CN'
  order by a.nom_, a.prn, c.annee asc;

hello;
my models are users, enca; encr;
who can i performe this query using django ORM, note that i'm using MSSQL; thank very much

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/85f7f91b-0f52-4a96-8700-bee588eb4a3d%40googlegroups.com.

No comments:

Post a Comment