July 23, 2003 at 5:19 am
The following query is supposed to increment a count everytime the condition is true..im just not sure about the syntax and the order of the statement etc........Thanks guys
declare @count int
select @count = 0
select t2.cust_id, t1.cust_id from unique_cust t1 INNER JOIN unique_cust t2
if t1.dup_code = t2.dup_code
select @count = @count+1
else select @count = 0
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
July 23, 2003 at 5:45 am
Basically, i want to read through the table and everytime the condition is met I want to increment the count..........
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!
July 23, 2003 at 9:04 am
Assuming the cust_id = dup_code, why not do a simple select count of all matching records between the two tables
SELECT @Count = COUNT(t1.*)
FROM unique_cust t1 INNER JOIN unique_cust t2 ON t1.cust_id = t2.cust_id
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply