• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Group By and Sum Issue

Participant ,
Oct 12, 2007 Oct 12, 2007

Copy link to clipboard

Copied

Can anyone please tell me how I can get the ins_id's to group so that the dollar amounts sum up properly? My SQL and current out put is listed below.

TOPICS
Advanced techniques

Views

470

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Oct 12, 2007 Oct 12, 2007
Okay. Is this the correct formula?
sum(p.pur_quantity) * t.tic_rate

Would
sum(p.pur_quantity * t.tic_rate)

return the same/correct results?

Votes

Translate

Translate
LEGEND ,
Oct 12, 2007 Oct 12, 2007

Copy link to clipboard

Copied

Do inner joins instead of outer joins.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 12, 2007 Oct 12, 2007

Copy link to clipboard

Copied

If you want the results grouped by INS_ID, why are you grouping by i.ins_id and t.tic_rate?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 12, 2007 Oct 12, 2007

Copy link to clipboard

Copied

Thanks for the reply.

Dan,
I can't do all INNER JOINS because not all the instances have tickets, and not all the ticket records have purchase records.

cf_dev2,
The good ol' fashion 'aggregate function' error throws when tic_rate is not in the group by clause.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 12, 2007 Oct 12, 2007

Copy link to clipboard

Copied

Okay. Is this the correct formula?
sum(p.pur_quantity) * t.tic_rate

Would
sum(p.pur_quantity * t.tic_rate)

return the same/correct results?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 12, 2007 Oct 12, 2007

Copy link to clipboard

Copied

LATEST
DEE-DE-DEEEE!!!

LMAO, Thanks that was it. Wow.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation