I'm trying to get a SQL query that lists all the nodes and their IPs, serials etc, however, the issue is that I want it to list also switch stacks and their members with their serials, not have them all as one node (Inventory purposes), I found an existing report that already has the following query but it's in swql and it also doesn't include custom properties and that's something I need:
SELECT OrionNodes.Caption, OrionNodes.DetailsUrl, OrionNodes.Status, OrionNodes.ChildStatus, NcmEntityPhysical.EntityName, OrionNodes.IP_Address, NcmEntityPhysical.EntityDescription, NcmEntityPhysical.Serial, NcmEntityPhysical.Manufacturer, NcmEntityPhysical.Model, NcmNodeProperties.NodeComments, OrionNodes.SysName, OrionNodes.NodeDescription, OrionNodes.Location, OrionNodes.Contact, OrionNodes.MachineType, OrionNodes.LastBoot, OrionNodes.IOSVersion
FROM NCM.NodeProperties AS NcmNodeProperties
INNER JOIN Orion.Nodes AS OrionNodes ON NcmNodeProperties.CoreNodeID=OrionNodes.NodeID
LEFT JOIN NCM.EntityPhysical AS NcmEntityPhysical ON NcmEntityPhysical.NodeID=NcmNodeProperties.NodeID AND (NcmEntityPhysical.EntityClass='3' OR NcmEntityPhysical.EntityClass='chassis(3)')
WHERE OrionNodes.Vendor='Cisco'
order by OrionNodes.Caption
How do I come up with something like this using SQL and also include custom properties in it?