How can I write a query to find machines which installed office 2003 with Sp3 in SCCM 2007?
The easiest way to do this is just to use reports rather than queries. There are built-in reports that will tell you all the machines with a particular version of a particular product installed. Have a look at the reports in the "Software - Companies and Products" category, like "Computers with a specific product name and version".
If however you actually do need a query, if for instance, you need to create a collection of all of these that you can advertise a specific software package to, then the easiest way is to search for a particular file that will be common to all of these machines.
For example, if you know that the install packages used in your company always install Outlook as part of Office, you could use a query like this that looks for the Outlook EXE file, and checks its version.
For example by setting these criteria in a query:
Or this is the query language that the above translates into (this can be pasted into the Show Query Language box):
For info, file versions for various Office versions and service packs can be found in these Technet pages: