I think you only need to join the custom properties table (line 3, below), and then add the custom property field to filter (line 5, below).
SELECT COUNT(InterfaceDescription) AS NumPorts, N.Caption FROM NCM.Interfaces I JOIN Orion.Nodes N ON (I.Node.CoreNodeID = N.NodeID) JOIN Orion.NodesCustomProperties AS NCP ON N.NodeID=NCP.NodeID WHERE NOT ((InterfaceTypeName like '%Virtual%') OR (InterfaceTypeName = 'other') OR (InterfaceTypeName like '%loop%')) AND NCP.Equipment_Type='SWITCHES' GROUP BY N.NodeID, N.Caption ORDER BY NumPorts DESC
Thank you,
-Will