I have the following table with the following columns:
HID_1 HID_2 Attr1 Attr2 Attr3 Attr4 Attr5
123 111 wo e ak ERR 20180630
123 111 wo e ak ERR 20180730
123 111 wo e ak ERR 20180830
123 111 qe e ak ERR 20180930
123 111 qe e ak ERR 20181030
123 111 aa a ak ERR 20181130
Where HID_1 and HID_2 are hash-id ad other 4 columns are defined by the group by statement and the last one is time_id(date of the last day of the month). In general in this table I have much more records with a lot of different HID.
I want to coumpute a number of changes(in Attr1 - Attr4) for the HID_2 as separate column. Based on the first example the answer should be like this:
HID_1 HID_2 Attr1 Attr2 Attr3 Attr4 Attr5 Attr6
123 111 wo e ak ERR 20180630 0
123 111 wo e ak ERR 20180730 0
123 111 wo e ak ERR 20180830 0
123 111 qe e ak ERR 20180930 1
123 111 qe e ak ERR 20181030 0
123 111 aa a ak ERR 20181130 2
How can I do in Oracle sql Database?
Try this:
I think you want: