Row-to-Column Transposition
【Question】
Here is the original SQL:
select day,registerCount,loginCount
from(
select day from date where day between 20120101 and 20120103)tmp
left join(
select registerCount from register)r on tmp.day=r.day
left join(
select loginCount from login)l on tmp.day=l.day
group by day;
This is the result set:
Now I want a result set in the form like this:
But I don’t know how to do this, is there any help?
【Answer】
A |
|
1 |
$select day,registerCount,loginCount from… |
2 |
=A1.pivot@r(day;type,count) |
3 |
=A2.pivot(type;day,count) |
A1: The original SQL query;
A2: Rotate column values in A1 to row values and the column headings registerCount and loginCount to the column values under type. Here’s the result set:
A3: Perform row-to-column transposition over A2 to rotate distinct values under day field into new field names.
The SPL script can be integrated with another application via esProc JDBC. For details, see .
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_SPL
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