我想采用以下两个语句并仅获得 2013 年的结果。
SELECT
COUNT(DISTINCT
CAST(c1.caseseqnumber AS VARCHAR) + '-' + CAST(c1.year AS VARCHAR)),
COUNT(DISTINCT
CAST(c2.caseseqnumber AS VARCHAR) + '-' + CAST(c2.year AS VARCHAR))
FROM
caseparticipants c1 LEFT JOIN caseparticipants c2
ON c1.year=c2.year AND c1.caseseqnumber=c2.caseseqnumber
AND c2.participanttype = 'Appellant Rep 1'
第二个
SELECT DISTINCT
c1.caseseqnumber,
c1.year
FROM
caseparticipants c1 LEFT JOIN caseparticipants c2
ON c1.year=c2.year AND c1.caseseqnumber=c2.caseseqnumber
AND c2.participanttype = 'Appellant Rep 1'
WHERE
c2.year IS NULL
Order by year ASC, Caseseqnumber ASC
谢谢!