Untitled
unknown
pgsql
2 years ago
2.4 kB
1
Indexable
Never
SELECT COUNT(*) OVER(), cases.id AS case_id, cases.status AS case_status, groups.name AS group_name, clients.name AS client_name, author.name AS author_name, process.process_number AS process_number, process.client_folder AS process_client_folder, cases.internal_id AS case_internal_id, deal.value_by_agreement AS deal_value_by_agreement, deal.payment_limit_date AS deal_payment_limit_date, deal.payment_type AS deal_payment_type, deal.proposals AS deal_proposals, deal.last_proposal AS deal_last_proposal, deal.duty_to_do AS deal_duty_to_do, deal.deal_status AS deal_status, deal.deal_limit_date AS deal_limit_date, deal.author_counter_proposal_value AS deal_author_counter_proposal_value, deal.author_counter_proposal_text AS deal_author_counter_proposal_text, deal.client_counter_proposal_value AS deal_client_counter_proposal_value, cases.processual_state AS case_processual_state, lawyer.name AS lawyer_name, oab.value AS lawyer_oab, lawyer.email AS lawyer_email, author.email AS author_email, lawyer.telephones AS lawyer_telephones, lawyer.whatsapp_numbers AS lawyer_whatsapp, author.telephones AS author_telephones, author.whatsapp_numbers AS author_whatsapp, deal.closed_deal_date AS deal_closed_deal_date, author.cpf AS author_cpf, process.district AS process_district, process.judgement AS process_judgement, process.state AS process_state, process.object AS process_object, cases.created_at AS case_created_at, cases.tenant_id AS case_tenant_id, task.task AS last_task FROM cases LEFT JOIN groups ON groups.id = cases.group_id LEFT JOIN clients ON clients.id = cases.client_id LEFT JOIN process_parties ON process_parties.process_id = cases.process_id LEFT JOIN persons AS author ON process_parties.person_id = author.id LEFT JOIN persons AS lawyer ON process_parties.lawyer_id = lawyer.id LEFT JOIN documents AS oab ON oab.person_id = lawyer.id LEFT JOIN processes AS process ON process.id = cases.process_id LEFT JOIN deals AS deal ON deal.id = cases.deal_id LEFT JOIN tasks AS task ON task.case_id = cases.id AND task.completed = false AND task.comment = 'Criado pela automação.' WHERE cases.is_active = true AND (process.process_number ILIKE '%TE7643%' OR author.name ILIKE '%TE7643%' OR cases.internal_id ILIKE '%TE7643%') ORDER BY cases.created_at DESC, cases.id DESC OFFSET 50 * 0 LIMIT 50;