Regarding your question about the static bikes in he gym, I find they help with training but aren't particularly accurate when it comes to speed. I even find there are quite big differences from bike to bike. You will always be slower, in my opinion on a bike cycling outdoors, as you have things like wind and hills to contend with, along with bends and junctions.
Having said that, I can currently maintain a speed of around 30kmph on my road bike on a flat road with no wind. This is also the speed that I tend to average on a static bike. My average speeds on the road bike tend to be around 25kmph however, depending on route and conditions. I'm doing my first ride in a race a week on Sunday, so I'm intrigued to see how I go. The distance is 17k as part of a sprint tri. On the static bike I can cover this distance in around 33mins. I've yet to do it in much less than 40mins on my road bike.
Both times I've raced over half marathon distance I've stopped to walk in the last mile. 1st time was the Coniston 14, and I think the hills did for me. 2nd time was last October in the Preston Guild Half. I was aiming for 1.45 and was well on target until the last mile. There were a couple of 'undulations' in the last mile, and I also went off too fast, and I stopped to walk about 3times in the last mile. Each time, someone overtook me and encouraged me to keep going as they did so. This spurred me on and got me going again. I finished in 1.45.53, a time I'm proud of, but just outside my target.
Both times, when I stopped to walk, I really felt that I couldn't keep running. It's not something I've done in any other races, or even in training, unless planned for. I didn't like stopping to walk, but I felt I had no option. I wish I knew who had encouraged me to keep going so I could thank them. That's one of he good things about racing.
In conclusion, I'd not done enough miles in training and I went off too fast. I'm proud of my times, but I do want to cover the distance without stopping to walk, and I do want to get under 1.45. I'm aiming to have a go later this year.