Skip to content
Advertisement

Pivot Table with Dynamic

My quest might be answered in somewhere here but I couldn’t find. So, sorry if I asked in vain.

I have a Table that’s populate automatically with precisely date/time in SQL Server and looks like this:

and I need something like this:

I need to do a pivot table based in this table where the Columns are Dat_Analise(date), Nom_operador(who did) and “Cod_Analise”(what did). And the rows are “Resultados”(results).

My problem is, i need to group by time period taking avg results for dynamic number of Cod_analises. But I even did the pivot with dynamic columns but I cannot fit the Group By part inside the pivot table.

I try to use a model that i found here and my procedure is like this:

Then:

And:

Hope you can help me guys and ,again, sorry if i did something wrong with this post. First time using this

Advertisement

Answer

Try to see the below query. Please, see UPDATE section of a pivot with column Nom_usuario.

Sample data:

A query:

And dynamic version:

OUTPUT:

UPDATE:

Use the following code snippet to show a Nom_usuario:

OUTPUT:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement