I tried the following solution mentioned here, to place two tables of unequal length, side by side.
\documentclass{article}
\usepackage{subcaption,booktabs}
\usepackage{multirow, makecell}
\begin{document}
\begin{table}[htb]%[!htb]
\caption{Main caption.}
\begin{subtable}[t]{.3\linewidth}
\raggedright
\begin{tabular}{c c ccc}
\toprule
\multirow{2.5}{}{$N$} & {\multirow{2.5}{}{\makecell[c]{ Multiple \parameters}}} &
\multicolumn{3}{c}{Values} \
\cmidrule{3-5}
& & X & Y & Z \
\midrule
\textbf{1}\\cmidrule{1-1}
& $D$ & 0.8 & 0.8 & 0.8 \
& $S$ & 0.8 & 0.8 & 0.8 \
\textbf{2}\\cmidrule{1-1}
& $D$ & 0.1 & 0.8 & 0.8 \
& $S$ & 0.8 & 0.8 & 0.8 \
\textbf{3}\\cmidrule{1-1}
& $D$ & 0.8 & 0.8 & 0.8 \
& $W$ & 0.8 & 0.8 & 0.8 \
\textbf{4}\\cmidrule{1-1}
& $S$ & 0.8 & 0.8 & 0.8 \
& $W$ & 0.8 & 0.8 & 0.8 \
\textbf{5}\\cmidrule{1-1}
& $S$ & 0.8 & 0.8 & 0.8 \
& $A$ & 0.8 & 0.8 & 0.8 \
\bottomrule
\end{tabular}
\end{subtable}%
\begin{subtable}[t]{.3\linewidth}
\raggedleft
\begin{tabular}{c c ccc}
\toprule
\multirow{2.5}{}{$N$} & {\multirow{2.5}{}{\makecell[c]{ Multiple \parameters}}} &
\multicolumn{3}{c}{Values} \
\cmidrule{3-5}
& & X & Y & Z \
\midrule
\textbf{1}\\cmidrule{1-1}
& $D$ & 0.8 & 0.8 & 0.8 \
& $S$ & 0.8 & 0.8 & 0.8 \
\textbf{2}\\cmidrule{1-1}
& $D$ & 0.1 & 0.7 & 0.8 \
& $S$ & 0.8 & 0.8 & 0.8 \
\textbf{3}\\cmidrule{1-1}
& $D$ & 0.8 & 0.8 & 0.8 \
& $W$ & 0.8 & 0.8 & 0.8 \
\bottomrule
\end{tabular}
\end{subtable}
\end{table}
\end{document}
The output is:
As apparent from the above image the tables are not top aligned and also they are overlapping. What mistake am I doing? Can someone please help me get the desired output?


\begin{tabular}[t]to top align but if the tables are too wide to fit they won't fit why are you specifying only .3\linewidth if you want two to fit not 3? .5 would give more room... – David Carlisle Feb 16 '22 at 09:05