  [Abridged] Far-infrared observations with Herschel revealed a surprisingly
low abundance of cold-water reservoirs in protoplanetary discs. On the other
hand, a handful of discs show emission of hot water transitions excited at
temperatures above a few hundred Kelvin. In particular, the protoplanetary
discs around the Herbig Ae stars HD 100546 and HD 163296 show opposite trends
in terms of cold versus hot water emission: in the first case, the ground-state
transitions are detected and the high-J lines are undetected, while the trend
is opposite in HD 163296. We performed a spectral analysis using the
thermo-chemical model DALI. We find that HD 163296 is characterised by a
water-rich (abundance $\gtrsim 10^{-5}$) hot inner disc (within the snowline)
and a water-poor ($< 10^{-10}$) outer disc: the relative abundance may be due
to the thermal desorption of icy grains that have migrated inward. Remarkably,
the size of the H$_2$O emitting region corresponds to a narrow dust gap visible
in the millimeter continuum at $r=10\,$au with ALMA. The low-J lines detected
in HD 100546 instead imply an abundance of a few $10^{-9}$ in the cold outer
disc ($> 40$ au). The emitting region of the cold H$_2$O transitions is
spatially coincident with that of the H$_2$O ice previously seen in the
near-infrared. Notably, millimetre observations with ALMA reveal the presence
of a large dust gap between nearly 40 and 150 au, likely opened by a massive
embedded protoplanet. In both discs, we find that the warm molecular layer in
the outer region (beyond the snow line) is highly depleted of water molecules,
implying an oxygen-poor chemical composition of the gas. We speculate that
gas-phase oxygen in the outer disc is readily depleted and its distribution in
the disc is tightly coupled to the dynamics of the dust grains.
