February 17, 2011 at 9:09 am
I need the sum of a column based on an if condition.
So I want the total number of occurances where the condition is true:
if (len(A_TowBoat) > 0 and
len(V_TowBoat) > 0)
OR
(len(A_TowBoat) = 0 and
len(V_TowBoat) = 0)
A_TowBoat and V_TowBoat are columns in my table.
February 17, 2011 at 9:39 am
Rog Saber (2/17/2011)
I need the sum of a column based on an if condition.So I want the total number of occurances where the condition is true:
if (len(A_TowBoat) > 0 and
len(V_TowBoat) > 0)
OR
(len(A_TowBoat) = 0 and
len(V_TowBoat) = 0)
A_TowBoat and V_TowBoat are columns in my table.
SELECT COUNT(*)
FROM MyUnnamedTable
WHERE (len(V_TowBoat) > 0 AND len(A_TowBoat) > 0)
OR (len(V_TowBoat) = 0 AND len(A_TowBoat) = 0)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
February 17, 2011 at 8:42 pm
Hi,
Sorry ignore this i got the question wrong.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply