1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] ALTERNATE TO SQL GROUPBY (such as to avoid repeating on aggregate fields)

Discussão em 'Outras Linguagens' iniciado por Stack, Novembro 8, 2024 às 08:12.

  1. Stack

    Stack Membro Participativo

    Is there any way to have a query return say 8 fields but only group by one field and perform only one aggregate function on another field? I get an error that suggests that i need to group by by all fields that do not have aggregate functions.

    I need to find the number of completed surveys for each month but need to include other information such as session starttime, session status, session id, etc.

    When I try to execute this:

    SELECT Datepart("m", starttime),
    COUNT(sessionid),
    sessionstatus,
    starttime,
    endtime,
    surveyid,
    surveybook,
    userdesk
    FROM survey_sessions
    GROUP BY Datepart("m", starttime)


    I get the error: "You tried to execute a query that does not include the specified expression 'SessionStatus' as part of an aggregate function"

    I do not need any other aggregates and grouping by the remaining fields does not give me ability to get the monthly total.

    Continue reading...

Compartilhe esta Página