I've tried
\begin{listing}
\begin{minted}{SQL}
SELECT COUNT(*) FROM lineitem
WHERE l_shipdate <= :shipdate
\end{minted}
\label{test}
\end{listing}
but it doesn't work. \cref{test} reference to the parent section
I've tried
\begin{listing}
\begin{minted}{SQL}
SELECT COUNT(*) FROM lineitem
WHERE l_shipdate <= :shipdate
\end{minted}
\label{test}
\end{listing}
but it doesn't work. \cref{test} reference to the parent section
You need something that has a number, i.e. a \caption:
\documentclass{article}
\usepackage{minted}
\usepackage{cleveref}
\begin{document}
\begin{listing}
\begin{minted}{SQL}
SELECT COUNT(*) FROM lineitem
WHERE l_shipdate <= :shipdate
\end{minted}
\caption{Testing}
\label{test}
\end{listing}
See \cref{test}.
\end{document}
\begin{minted}[frame=lines]{SQL}, but the manual mentions that both the tcolorbox and mdframed packages have interfaces for minted, so in that sense there is a lot of flexibility with regard to frames. To move the caption to the top, see https://tex.stackexchange.com/a/256796/586
– Torbjørn T.
Jun 30 '17 at 18:19
\documentclassand ending with\end{document}. – Bobyandbob Jun 30 '17 at 14:57