Problem whit a query

  • Hi

    i have the following query:

    SELECT E.IDEmisionSeriada,

    YEAR(S.FechaPrestamo) AS [Año],

    COUNT(*) AS Seriadas, @FechaIni as FechaInicial, @FechaFin as FEchaFinal, @Tipo as Material

    from dbo.Servicios S, Ejemplares E, EmisionesSeriadas ES

    where S.CodigoAcceso = E.CodigoAcceso

    and E.IDEmisionSeriada = ES.IDEmisionSeriada

    and S.FechaPrestamo IS NOT NULL

    and S.FechaPrestamo between @FechaIni and @FechaFin

    GROUP BY E.IDEmisionSeriada,

    YEAR(S.FechaPrestamo)

    In this query i group by Year, but i need to group whit semester, how can i do this?

    thank you any help

  • EIAnd (6/7/2009)


    In this query i group by Year, but i need to group whit semester, how can i do this?

    Hi,

    A bit question,

    In your statement which one is the semester column?

    and or how many semester is one year?

    ARUN SAS

  • hi,

    a year have 2 semesters.

    i dont have a column name semester, i need to change the year for semester.

    thank you for your help 🙂

  • Hi,

    Try this,

    SELECT E.IDEmisionSeriada,

    YEAR(S.FechaPrestamo) AS [Año],

    -- START

    (case when MONTH(S.FechaPrestamo) <=6 then 'First Seme' else 'Second Seme' end)Semester

    -- END

    COUNT(*) AS Seriadas,

    @FechaIni as FechaInicial,

    @FechaFin as FEchaFinal,

    @Tipo as Material

    from dbo.Servicios S,

    Ejemplares E,

    EmisionesSeriadas ES

    where S.CodigoAcceso = E.CodigoAcceso

    and E.IDEmisionSeriada = ES.IDEmisionSeriada

    and S.FechaPrestamo IS NOT NULL

    and S.FechaPrestamo between @FechaIni and @FechaFin

    GROUP BY

    E.IDEmisionSeriada,

    YEAR(S.FechaPrestamo),

    --start

    (case when MONTH(S.FechaPrestamo) <=6 then 'First Seme' else 'Second Seme' end)

    --END

    ARUN SAS

  • thank very mutch Arun Sas works pretty good.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply