Sometimes this cannot be fixed if it has gone on for too long, or if it is, it may be temporary.
You will need to ensure that your tank water is very clean, and you will need to stop feeding your goldfish for 3 days to give it's system a rest. Next, you need to feed it cooked & de-shelled peas 2 times a day for 3 days (it will not be very many peas over those 3 days) with a small grain of epsom salt in one of the pieces of pea each day. Peas and epsom salt are a form of laxatives for goldfish and should help them clear out their system.
Swim bladder is commonly caused by constipation, but in some cases, it's a faulty swim bladder for that particular fish.
A damaged swim bladder.
To the best of my knowledge there is no reliable/proveable cure for swim bladder problems. I am aware that there are (quite expensive) medications available at pet shops that claim to cure just about everything including swim bladder problems but I have yet to hear of one actually working and curing this problem. I have spent a fortune in pet shops over the years and have learned that there is no reliable water additive or medical cure for swim bladder problems. My advice is to euthanise the fish.
Take it to the vet
Your fish has a swim bladder problem. There is no known effective cure. The fish will die eventually. I would advise 'euthanasia'.
Yes, just feed it frozen mashed peas.
Swim bladder disease? http://www.straightdope.com/columns/read/1688/if-a-goldfish-is-swimming-on-its-side-is-this-a-bad-sign
no,but they have oil rich livers.It prevents them from sinking when they are not swimming. but some fishes have swim bladders. ex:guppies,goldfish..........
Severe swim bladder problems (feed 'em mashed peas), or it's dead.
If your goldfish is struggling to go down to the bottom of the tank it has a swim bladder problem. There are those who advise a slow raising (up to 80F) and then lowering (down to 55F) of the temperature of the water over about two days for this problem. There are also commercially available "cure alls" that pet shops will happily recommend and sell you. In over 50 years of fish keeping I have yet to see either the temperature manipulation or any of the expensive medications work and fix a swim bladder problem. In my experience the fish will eventually die so I would euthanase it.
Feed Betta little peice of a boiled Pea.
An upside down goldfish means it has a swim bladder disease. If that disease is detected on your goldfish early, it is treatable with isolation and medicated food. But if the disease is detected too late, the results are irreversible-it is a deadly disease.
What else would you expect them to swim in? Of course Goldfish swim in water.