Require correct of query .. I am new in SQL Server

Occasional Contributor

Hi

I need 6 month avg for each Ticket id . i have written below query but did get correct Average output. Please can you make it correct . i think i need to use subquery on it but i dont know how . Please suggest

 

select o.id,o.name as Org_Name ,pt.id as Ticket_ID, pt.date_created,
 pt.date_created  as Date_months, count(pt.id) AS TicketCount,
(count(pt.id))/6 AS TicketAV
from organization o
join project_task pt on pt.org_id = o.id
where pt.date_created >= '2021-01-01'

4 Replies

but did get correct Average output.


@Trilok_Bohra , and in which way is the result not correct?

 

(count(pt.id))/6

What for result do you expect here; some count divided by 6?

 

Please post table design as DDL, some sample data as DML statement and the expected result.

@olafhelper 

i can't share the data. its on my office system. we don't have access right . so i can share you the output file in xls format. i am looking the output with same manner

It has been done now .thanks
Two way street here, Trilock... please post the query that worked for you so that others may learn