SQL Question Using PIVOT, No Aggregation Column
Question
Source:https://stackoverflow.com/questions/70511664/sql-question-using-pivot-no-aggregation-column
I would like to do a PIVOT on my table but I don't have aggregation column.
SELECT
CONVERT(date, DataHora) AS dia,
CONVERT(VARCHAR(5), DataHora, 108) AS hora
FROM
[clientes].[dbo].[Tb_Ponto]
Result:
2021-12-27 12:41
2021-12-28 12:42
2021-12-28 13:03
2021-12-28 14:08
I would like it to stay like this:
2021-12-27 12:41 | NULL | NULL
2021-12-28 12:42 | 13:03 | 14:08
Answer
A |
|
1 |
=MSSQL.query("SELECT CONVERT(date, DataHora) AS dia,CONVERT(VARCHAR(5), DataHora, 108)AS hora FROM [clientes].[dbo].[Tb_Ponto] ORDER BY 1,2") |
2 |
=A1.derive("hora"/ranki(#2;#1):fn).pivot(#1;#3,#2) |
View SPL source code.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL
Chinese version