I have to find a count for a combination of columns:
JobsName date check calculatedField
Job1 2/2/2020 check1 1
Job1 2/2/2020 check2 1
Job1 3/2/2020 check1 2
Job3 4/2/2020 check1 3
Job3 4/2/2020 check2 3
Job3 4/2/2020 check3 3
Job4 5/2/2020 check3 4
add 1 to the caucluatedField whenever a JobsName has a new date on which it ran.
Iy your database supports window functions, you can just use dense_rank()
:
select
t.*,
dense_rank() over(order by date) calculatedField
from mytable t
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.