If you want to get
really technical about it, no submarine has ever had a deck gun. By the time the first true submarine craft were introduced (rather than submersible torpedo-boats) the practicality of the deck gun had long since vanished.
Anyway, I hope this site helps:
http://pigboats.com/subs/deckguns/deckguns.html
According to them, the case could be made for the
Holland having the first deck gun.