Help with SQL query

Tags:
SQL
SQL Query
Dear friends, I am working on squirrel and wrote a query which is like this:
select
sum((coalesce((Sent_128),0)))*(365/(count(distinct(date_created))))/(((sum(coalesce((quantity2),0))/(count(distinct(date_created))))+(sum(coalesce((qu antity),0))/(count(distinct(date_created)))))/2) as "final"
from table....
I'm getting error as:
Error: TEIID30504 Remote org.teiid.core.TeiidProcessingException: TEIID30504 dwhSOU: 0 TEIID11008:FEHLER: Division durch Null:TEIID11004 Error executing statement(s): [Prepared Values: [] SQL: SELECT ((SUM(coalesce(g_0."sent_128", 0)) * cast((365 / COUNT(DISTINCT g_0."date_created")) AS bigint)) / (((SUM(coalesce(g_0."quantity2", 0)) / cast(COUNT(DISTINCT g_0."date_created") AS bigint)) + (SUM(coalesce(g_0."quantity", 0)) / cast(COUNT(DISTINCT g_0."date_created") AS bigint))) / 2)) AS "c_0" FROM dwh.mat_table_17799_st113 AS g_0, dwh.mat_table_21359_st2 AS g_1 WHERE g_0."sku" = g_1."supplier_sku" GROUP BY g_0."pop_quantity", g_0."pop_fulfilled_quantity", g_0."returned_512", g_0."quantity", g_0."reserved" LIMIT 100]
Please help me out with the error. Thanks in advance.

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    The first thing I noticed is this:

    sum(coalesce((qu antity),0)

    But it could help looking at the complete query if correcting this doesn't help.
    68,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following