SCCM Configmgr SQL Report get list of machines with one Version of application and exclude other versions

I had requirement from team to find out the clients that have one application (example Java) with one version installed and exclude clients that have multiple versions with same application installed. Lets take simple example . I have clients CLN01,CLN02,CLN03 and CLN04 and they have different versions of Java application installed on them. PC Name…