# Getting values from NULLs

I have this Query:

``````SELECT
COUNT(x.dwActualNumberOfDoffings) AS 'DoffCount'
,x.sRecipeName AS 'Denier'
,SUM(Shift_Weight) AS 'Shift_LBS'
,SUM(Shift_Length) AS 'Shift_Meters'
FROM
(
SELECT
dwActualNumberOfDoffings
,sRecipeName
,CASE
WHEN sRecipeName = '1385 denier' THEN (42000)
WHEN sRecipeName = '1411 Denier' THEN (31500)
WHEN sRecipeName = '1426 Denier' THEN (38000)
WHEN sRecipeName = '1700 Denier' THEN (26000)
ELSE NULL
END 'Shift_Length'
,CASE
WHEN sRecipeName = '1385 denier' THEN (14.2)
WHEN sRecipeName = '1411 Denier' THEN (10.9)
WHEN sRecipeName = '1426 Denier' THEN (13.9)
WHEN sRecipeName = '1700 Denier' THEN (10.8)
ELSE NULL
END 'Shift_Weight'
FROM BitWinder_1_LH
WHERE dwActualNumberOfDoffings >= 1
AND t_stamp BETWEEN '2022-07-01 08:00:00' AND '2022-07-31 20:00:00'
) AS x
GROUP BY x.sRecipeName
``````

And it returns this:

I am trying to have the Columns that have NULL return a value based off a calculation, something like this: (if denier = 1411 then doffcount * 10.8 = shift_lbs) Im just not sure how to input it into the query.

Any help would be great.

Would it be better to fix why youâ€™re getting nulls in the fist place? The leading whitespace in the Denier columnâ€™s last two rows gives it away. Unless there is a reason for it.

1 Like

Yep that would be better, I didnt notice that white space. That much better. I can fix that easy. Thanks alot for the different set of eyes.

1 Like