Engine?
Year?
Miles?
There are a number of similar problems discussed at length in these forums.
Ideally you should change the transmission fluid if it is due. This alone may fix the problem.
Next you can change the TSS for around $40, this could also be the problem.
Internal problems like the pump or valve body will cost you much more.
Of note - if the PCM gets confused about engine conditions it can shift funny. In this case you should also notice a loss of power or engine bucking, you may also but not necessarily get a code.