Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to display qty 1 time

Author  Topic 

PoseyRobert
Starting Member

27 Posts

Posted - 2015-01-07 : 15:36:07

Hi

I have a temp table that I would like to only display the Qty of 4 one time

The total Qty is 4

Part Fac Loc Lot Qty
===== === === === ===
8793 07 FG 111 4
8793 07 FG 122 4
8793 07 FG 113 4
8793 07 FG 144 4

I want to display Qty 4 so when I do a sum I do not get qTY 16

Part Fac Loc Lot Qty
===== === === === ===
8793 07 FG 111 4
8793 07 FG 122 0
8793 07 FG 113 0
8793 07 FG 144 0

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-01-07 : 15:42:15
Simplistic, but:


select Part, Fac, Lot
, case when Lot = 111 then Qty
else 0
end as Qty
...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2015-01-08 : 01:42:05
What if your data is

Part Fac Loc Lot Qty
===== === === === ===
8793 07 FG 111 4
8793 07 FG 122 3
8793 07 FG 113 3
8793 07 FG 144 4

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -