Forum Discussion

Trilok_Bohra's avatar
Trilok_Bohra
Copper Contributor
Jan 05, 2022

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

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'

  • olafhelper's avatar
    olafhelper
    Bronze Contributor

    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.

    • Trilok_Bohra's avatar
      Trilok_Bohra
      Copper Contributor

      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

Resources