There is already a report at:
Reports -> All Reports -> Discovery and Inventory -> Inventory -> Cross-platform -> Hardware -> Memory -> Memory Configuration by Computer
You can even use it's SQL query as a template if this is not exactly what you want.