|
Почему при обертывании в функцию данные разные
|
|||
---|---|---|---|
#18+
Запрос select cd.cnt, ab.cnt from (select count(a.A_OUID) as cnt from NTF_MESSAGE a /*всего отправлено смс*/ join NTF_MSG_TYPES_LINK b on b.ATTRA=a.A_OUID where b.ATTRb=10322418 and a.a_createdate>='2020-08-10 15:00:01.658' and a.a_createdate<='2020-08-12 15:00:00.382' )cd join (select count(a.A_OUID) as cnt from NTF_MESSAGE a /*всего доставлено смс*/ join NTF_MSG_TYPES_LINK b on b.ATTRA=a.A_OUID join NTF_MESSAGE_LOG c on c.a_message=a.A_OUID where b.ATTRb=10322418 and a.a_createdate>='2020-08-10 15:00:01.658' and a.a_createdate<='2020-08-12 15:00:00.382' and c.a_createdate>='2020-08-10 15:00:01.658' and c.a_createdate<='2020-08-12 15:00:00.382' and c.a_success is true) ab on 1=1 При обертывании в функцию CREATE OR REPLACE FUNCTION getMessages_sms(begindate date, enddate date) RETURNS table("outsms" bigint, "delivsms" bigint) LANGUAGE plpgsql AS $body$ begin RETURN QUERY select outsms.cnt as "outsms", delivsms.cnt as "delivsms" from (select count(a.A_OUID) as cnt from NTF_MESSAGE a /*всего отправлено смс*/ join NTF_MSG_TYPES_LINK b on b.ATTRA=a.A_OUID where b.ATTRb=10322418 and a.a_createdate>=begindate and a.a_createdate<=enddate ) outsms join (select count(a.A_OUID) as cnt from NTF_MESSAGE a /*всего доставлено смс*/ join NTF_MSG_TYPES_LINK b on b.ATTRA=a.A_OUID join NTF_MESSAGE_LOG c on c.a_message=a.A_OUID where b.ATTRb=10322418 and a.a_createdate>=begindate and a.a_createdate<=enddate and c.a_createdate>=begindate and c.a_createdate<=enddate and c.a_success is true) delivsms on 1=1 ; end; $body$; При вызове с теми же параметрами select * from getMessages_sms('2020-08-10 15:00:01.658','2020-08-12 15:00:00.382') Данные очень сильно отличаются, в чем может быть причина? ... |
|||
:
Нравится:
Не нравится:
|
|||
03.09.2020, 08:49 |
|
Почему при обертывании в функцию данные разные
|
|||
---|---|---|---|
#18+
TanyaBlaginina, В определении функции begindate,enddate объявлены c типом date , замените на timestamp . ... |
|||
:
Нравится:
Не нравится:
|
|||
03.09.2020, 09:01 |
|
|
start [/forum/topic.php?fid=53&fpage=23&tid=1994489]: |
0ms |
get settings: |
9ms |
get forum list: |
12ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
29ms |
get topic data: |
11ms |
get forum data: |
2ms |
get page messages: |
40ms |
get tp. blocked users: |
1ms |
others: | 14ms |
total: | 124ms |
0 / 0 |