• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

194
Views
fusionarse con la función de filtro en postgresql

Estoy ejecutando esta consulta:

 SELECT SUM(PRICE) FILTER (my filter's parameters)

y cuando no hay registro devuelve <null>

luego probé:

 SELECT COALESCE(SUM(PRICE),0) FILTER (my filter's parameters)

Pero luego aparece un error FILTER not valid for coalesce function

los parámetros de mi filtro son una ventana de tiempo, así:

 FILTER(WHERE date(order_date) >= (cast(current_date as date) - interval '1' day)) as day1

¿Cómo puedo reemplazar <null> by 0 cuando no hay registro?

about 3 years ago · Santiago Trujillo
1 answers
Answer question

0

Debería intentar envolver toda la expresión FILTER en COALESCE , por ejemplo

 SELECT COALESCE(SUM(PRICE) FILTER (my filter's parameters), 0) AS sum_price
about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error