question

nanibarkman avatar image
nanibarkman asked

How can I prevent duplicate lines?

Hi all,

I'm having an issue where TotalShippedQTY is being multiplied by the number of lines associated with one order. The duplication is coming from 3 different fields, EventCode, ExceptionCode, and EventDateTime. Each order can have different EventCodes, ExceptionCodes, and EventDateTimes. I need to someone show all of them, but not duplicate the TotalShippedQty.

I tried using this case statement, but it didn't work.

CASE WHEN COUNT(DetailsTable.exception_code) >1

THEN (PartOne.TotalShippedQTY/(COUNT(DetailsTable.exception_code)))

ELSE PartOne.TotalShippedQTY

END AS TtlShippedQTY

duplicate valuesduplicate
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·

Perhaps you could provide some sample data and results (both expected and what you're getting) and your query so we can see exactly what you're doing?

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.