MSSQL - make select form in the result the fields do not appear repeated

Asked

Viewed 73 times

1

inserir a descrição da imagem aqui

The select I’m making is this:

SELECT DISTINCT dbo.Entity.ComercialName
    ,dbo.ScheduleStatus.Description
    ,dbo.ScheduleGoal.Description AS alias_DSG
    ,dbo.ScheduleType.Description AS alias_DST
    ,dbo.Entity.ID
    ,dbo.Schedule.Notes
    ,dbo.Schedule.DATE
FROM (
    dbo.Schedule RIGHT JOIN dbo.ScheduleStatus ON ScheduleStatus.id = Schedule.ScheduleStatus
    )
RIGHT JOIN dbo.ScheduleGoal ON Schedule.ScheduleGoal = ScheduleGoal.Id
RIGHT JOIN dbo.ScheduleType ON Schedule.ScheduleType = ScheduleType.id
RIGHT JOIN dbo.Entity ON SChedule.Entity = Entity.Id
GROUP BY Entity.ComercialName
    ,ScheduleStatus.Description
    ,ScheduleGoal.Description
    ,ScheduleType.Description
    ,Entity.ID
    ,Schedule.Notes
    ,Schedule.DATE;

The result I desire is:

Resultado Final

  • It seems that this result is acquired at the time of encoding the appearance of the report, and not directly in the table of the resulting database. In the case of scheduling the report design events in the application source code.

  • But you could do this with a recursive SQL code using UNION ALL of a result with the first columns, and a result of the other results after the first, of each row of the first result. It would have to be dynamic SQL.

  • and how do I do it? when doing UNION ALL it will join the repeated fields?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.