             "(select jar_name, group_name, max(created) as created "
             "from jars "
             "where group_name = ? "
+            (when artifact-id "and jar_name = ? ")
             "group by group_name, jar_name) l "
             "on j.jar_name = l.jar_name "
             "and j.group_name = l.group_name "

            "from jars "
            "where version not like '%-SNAPSHOT' "
            "and group_name = ? "
            "group by group_name, jar_name) r "
            "on j.jar_name = r.jar_name "
            "and j.group_name = r.group_name "

            "left join "
            "(select jar_name, group_name, version, created from jars "
            "where group_name = ? "
            (when artifact-id "and jar_name = ? ")
            ") as r2 "
            "on j.jar_name = r2.jar_name "
            "and j.group_name = r2.group_name "
