I have a table and the data is in below format.
I need the query in databricks sql
I have tried self join and some lag functions but it doesn't work. Please let me know if I am not making any sense.
Thanks, MG
I have a table and the data is in below format.
I need the query in databricks sql
I have tried self join and some lag functions but it doesn't work. Please let me know if I am not making any sense.
Thanks, MG
You can do join on the tables filtered on column
Subcategory
to get your desired results.Use below code for it.
Here, i am filtering the records on
Subcategory
and joining them on sameProgramid
,Category
,ReportMon
andReportYea
.Output: