COUNT THE RECORDS IN MY SELECTION

Database
Enthusiast

COUNT THE RECORDS IN MY SELECTION

Hi everyone,

I have two tables in teradata that I am trying to combine:

1) A_EXODUS_BASE.Audit_entry with columns:

audit_event_identifer
audit_date
USER_STAFF_NUMBER

2) D_UKRB_BND.MR_fte with:
staff_id
effective_start_date
effective_end date

I am trying to download the recordds for 2010 where the staff_id matches table two. This is my query:

select tx.audiT_EVENT_IDENTIFIER, count(tx.event_identifier)

from A_EXODUS_BASE.Audit_entry tx

inner join D_UKRB_BND.MR_fte mp

on tx.USER_STAFF_NUMBER=mp.staff_id

where tx.audit_date between mp.effective_start_date and mp.effective_end_date

and tx.audit_date between '2010-01-01' and '2010-12-31'

group by tx.audiT_EVENT_IDENTIFIER

Can someone please confirm if I am using the count statement correctly? I am not sure if I am double counting or if my statement is correct.
I just want to count the number of records for each audit_event that match my select statment.

Any help will be much appreciated.
2 REPLIES
Enthusiast

Re: COUNT THE RECORDS IN MY SELECTION

Hello,
Could someone coment on this topic please? I would like to know if my query is 100% ocrrect.

Thanks ,m

Re: COUNT THE RECORDS IN MY SELECTION

Since you are gouping on audiT_EVENT_IDENTIFIER column so this query will give you the count of event_identifier for each values of audiT_EVENT_IDENTIFIER in year 2010.
if you just want the count of all event_identifier (not classified on audiT_EVENT_IDENTIFIER level) then you should remove audiT_EVENT_IDENTIFIER column from the select list and gouping by clause should be remove.

hope this help .....

Cheers,
Amit S.