"Group by" is what you're looking for.
select lgsesn, count(*) as hitcount
FROM anloga
WHERE LGSESN NOT LIKE '%ARCHIVE%'
group by LGSESN
order by LGSESN
There's a way to get both the detail, and the control breaks, with the
latest releases of sql. Not to be disparaging but I don't think you're
ready for that level though.
I've read "SQL/400 Developer's Guide" by Paul Conte and Mike Cravitz.
Copyright 2000. Ok, a little dated and doesn't include some of the newer
stuff but it will definitely help you. After all, it's a guide, not a
reference manual.
Rob Berendt