Fordraiders
asked on
need calculation for avg number of counts per day.
need calculation for avg number of counts per day.
I have 3 fields
Create_date
status - text
nsc_id - primary id autonumber
I have about 30,00 records in table
i.e. below
12/1/2019 7:11:43 AM completed 1
12/1/2019 7:00:43 AM completed 2
12/1/2019 7:12:43 AM completed 3
12/2/2019 7:05:43 AM open 4
12/2/2019 7:11:43 AM completed 5
12/2/2019 7:00:43 AM completed 6
12/2/2019 7:12:43 AM open 7
12/2/2019 7:05:43 AM open 8
What I need:
I will be looking at all 2019 records so i need to know on the avg how many status that are "completed" for a given day
on 12/1 3 were completed
on 12/2 2 were completed
so on the avg 2.5 are completed in a given day
Thanks
fordraiders
I have 3 fields
Create_date
status - text
nsc_id - primary id autonumber
I have about 30,00 records in table
i.e. below
12/1/2019 7:11:43 AM completed 1
12/1/2019 7:00:43 AM completed 2
12/1/2019 7:12:43 AM completed 3
12/2/2019 7:05:43 AM open 4
12/2/2019 7:11:43 AM completed 5
12/2/2019 7:00:43 AM completed 6
12/2/2019 7:12:43 AM open 7
12/2/2019 7:05:43 AM open 8
What I need:
I will be looking at all 2019 records so i need to know on the avg how many status that are "completed" for a given day
on 12/1 3 were completed
on 12/2 2 were completed
so on the avg 2.5 are completed in a given day
Thanks
fordraiders
SELECT AVG(completed_count) AS avg_daily_completed, COUNT(*) AS days_with_completion
FROM (
SELECT
DATEADD(DAY, DATEDIFF(DAY, 0, create_date), 0) AS create_day,
COUNT(*) AS completed_count
FROM dbo.table_name
WHERE status = 'completed' AND
create_date >= '20190101' AND create_date < '20200101'
GROUP BY DATEADD(DAY, DATEDIFF(DAY, 0, create_date), 0)
) AS query1
ASKER
SCOTT, giving me a parameter prompt on DAY
ASKER
this is access vba ...Not sql server sorry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
different field names but that worked.
query1
SELECT Count(dbo_t_nsc_trackcode_ assigned_D ataEntry.N SC_Id) AS CountOfNSC_Id, DateValue([opened_date]) AS DateOpen
FROM assigned_DataEntry
GROUP BY DateValue([opened_date])
ORDER BY DateValue([opened_date]) DESC;
and
query2
SELECT Avg(CountPerDay.CountOfNSC _Id) AS AvgOfCountOfNSC_Id
FROM CountPerDay
query1
SELECT Count(dbo_t_nsc_trackcode_
FROM assigned_DataEntry
GROUP BY DateValue([opened_date])
ORDER BY DateValue([opened_date]) DESC;
and
query2
SELECT Avg(CountPerDay.CountOfNSC
FROM CountPerDay
ASKER
thanks scott
Open in new window