There are gas WH that can vent out a sidewall, but many can't - they need a flue that rises to the roof. If you get one that can vent out a sidewall, each manufacturer has specific rules on where it can be relative to a window, door, overhang, and the ground (can't be below the normal snow level). There are several different ways a gas appliance can be vented: natural vent requires a flue up to the roof; power vent, can often vent out a sidewall, and is also used when the flue is too long (which cools the gasses off and can be problematic) and could go to the roof; and closed combustion which normally goes out a sidewall, but could also go out the roof. Closed combustion is similar to a power vent, but in addition to blowing the exhaust out, it also provides a closed supply of fresh air to the burner. This last type is often the most efficient, but also costs more to buy. Generally, the code specifies "installed per the manufacturer's instructions and national/local codes". So, while the code issues might cover a bit of it, it gets more specific once you've decided on a particular brand and model.