I have these 3 queries - they are the same except each fetches record counts
for one of 3 different record types, nSubsets (type 0), nAssets (type 1) and
nImages (type 2). Is there any way I could get all 3 of these (based on the
Node.Type integer) with a single query?
IF @Error = 0
BEGIN
SELECT @nSubsets = COUNT(*)
FROM Node
INNER JOIN Adjacency
ON Adjacency.ID_Node = Node.ID
WHERE Adjacency.Path LIKE @nodepath + '%'
AND
Node.Type = 0
SET @Error = @ERROR
END
IF @Error = 0
BEGIN
SELECT @nAssets = COUNT(*)
FROM Node
INNER JOIN Adjacency
ON Adjacency.ID_Node = Node.ID
WHERE Adjacency.Path LIKE @nodepath + '%'
AND
Node.Type = 1
SET @Error = @ERROR
END
IF @Error = 0
BEGIN
SELECT @nImages = COUNT(*)
FROM Node
INNER JOIN Adjacency
ON Adjacency.ID_Node = Node.ID
WHERE Adjacency.Path LIKE @nodepath + '%'
AND
Node.Type = 2
SET @Error = @ERROR
END