Hi issuer,

Plz refer to docs to customize statement base on your use case, my work for
a sample with limited time. Plz try remove space around equal sign.



On Tue, Dec 3, 2019, 19:26 bill dexter <55dexte...@gmail.com> wrote:

> hi friend;
> i tryed your answer, but it says that error in syntax near  __gt  in ""
> extractyear(dat_enc) - extractyear(annee)__gt = 3""; don't work
>
> Le lun. 2 déc. 2019 à 20:31, Integr@te System <datacentral...@gmail.com>
> a écrit :
>
>> Hi friend,
>>
>> All_list = list(users.object.aggregate(age =
>> cast(extractyear(datetime.now()) - extractyear(dat_nais), output_field =
>> IntField())).filter(extractyear(dat_enc) - extractyear(annee)__gt = 3 & 
>> extractyear(datetime.now())
>> - extractyear(dat_nais)__IN=range(54,70) & cod_nad__contain = 
>> 'CN').order_by('num___annee',
>> 'prn'))
>>
>>
>> Plz add more alias field as your sql command according to a sample above.
>>
>> Ps: check your question first(sql), then pass to communities.
>>
>>
>>
>> On Mon, Dec 2, 2019, 21:16 bill dexter <55dexte...@gmail.com> wrote:
>>
>>> thank you, but if you can give me answer to this  exacte probleme, as
>>> mentioned in question
>>>
>>> Le dim. 1 déc. 2019 à 18:55, Integr@te System <datacentral...@gmail.com>
>>> a écrit :
>>>
>>>> Hi,
>>>>
>>>> here u can try for complex queryset
>>>>
>>>>
>>>>
>>>> https://docs.djangoproject.com/en/2.2/topics/db/queries/#complex-lookups-with-q
>>>>
>>>> On Sun, Dec 1, 2019, 21:08 bill dexter <55dexte...@gmail.com> wrote:
>>>>
>>>>> 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+unsubscr...@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
>>>>> <https://groups.google.com/d/msgid/django-users/85f7f91b-0f52-4a96-8700-bee588eb4a3d%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> 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+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/CAP5HUWqap3ddCEmW-7yD_uRWhwxDNQdSNZ%2BQPPvHzcAwDf1e5Q%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAP5HUWqap3ddCEmW-7yD_uRWhwxDNQdSNZ%2BQPPvHzcAwDf1e5Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> 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+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAA7%3DR20i-DNEFTgdHQ7bjmvzQHrmML3LjzamrSiK07oJgbC_%2Bw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAA7%3DR20i-DNEFTgdHQ7bjmvzQHrmML3LjzamrSiK07oJgbC_%2Bw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAP5HUWoRjYGOMbQf2Lz9npLi7%2BhsOfDoN-wYLAUAjbr9ites-Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAP5HUWoRjYGOMbQf2Lz9npLi7%2BhsOfDoN-wYLAUAjbr9ites-Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAA7%3DR22g%3DsVQJA1d4JdBC-biw%2BzcRCec9FPn_rbnBNo7%2B2%3DkTw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAA7%3DR22g%3DsVQJA1d4JdBC-biw%2BzcRCec9FPn_rbnBNo7%2B2%3DkTw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP5HUWpmhnjXcaEDD4tYB9PkGzHJs71jHWxCFASq5--9puWtaA%40mail.gmail.com.

Reply via email to