I have a table that has a container type (in this case) PL. I need to count the records where the container type = 'PL'. I have tries CASE and a straight count but a I get 3 records instead of 1 since only one record has the containr type of pallet.
For the example belwo i soulf only get 1 as the result
What would be the best way to count the records with container type = PL. Any help with this is apreciated
Thanks in advance
RJL
Code:
SELECT
COUNT(
CASE
WHEN SC.CONTAINER_TYPE = 'PL' THEN 1 ELSE 0
END) AS 'PALLETS'
FROM
SHIPPING_CONTAINER SC WITH(NOLOCK)
WHERE
SC.INTERNAL_SHIPMENT_NUM = 121386
For the example belwo i soulf only get 1 as the result
Code:
TREE_UNIT CONTAINER_ID SHIPMENT_ID CONTAINER_TYPE
8026942 00080269427C 33787 PL
8026942 33787 -
8026942 33787 -
What would be the best way to count the records with container type = PL. Any help with this is apreciated
Thanks in advance
RJL