That depends on local council rules.
I don't know of any hard set rules but common sense tells me that it should be at least 4 feet from the edge of the pool to allow access. The previous is correct because it is always a good idea to consult with you local department of inspections or other governing body. When you build your fence keep in mind that a new national pool code was signed into law in December 2007. It is call The Virginia Graeme Baker Pool & Spa Safety Act of 2007. This act puts the Consumer Product Safety Commission (CPSC) in charge of the pool laws. They already have several publications on the subject.