Count Distinct
Posted in 1996
Hi,
I'm having trouble getting a count from a labels program. I have 2 tables
(labels, donor) the labels table has name, address, etc and the donor table
has dollar amounts, dates,etc. I can select and print out the labels ok but
I'm having trouble using the count function to get a total of the labels I
just printed. I get a number much larger than what was printed. I know the
number includes duplicate rows but haven't been successful using count distinct
or unique.
Here's a portion of the program. I'd appreciate any push in the right
direction. Thanks, Joe.
select id_number,last_name,company,first_name,address,city_state,zip_code,
greeting,source,comment
did_number,ddonor_date,damount,dnoncashdescrip
from labels,donor
where ddonor_date >=$startdate and ddonor_date <=$enddate
and did_number=id_number
order by zip_code,last_name,company
end
format
after group of company
if greeting is not null then
print greeting clipped, 1 space, first_name clipped, 1 space, last_name
else
print first_name clipped, 1 space, last_name
if company is not null then
print company without trailing blanks
print address
print city_state clipped, 1 space, zip_code
if company is null then
skip 3 lines
else
skip 2 lines
on last row
print "Total Labels Printed: ",count
end