# AQL VersionedObject Grammar **Category:** [Technical (archive)](https://discourse.openehr.org/c/technical-archive/156) **Created:** 2011-07-19 05:50 UTC **Views:** 7 **Replies:** 4 **URL:** https://discourse.openehr.org/t/aql-versionedobject-grammar/14186 --- ## Post #1 by @Mahdi_Asgari Hi dear All I confuse to make a AQL query using versioned_object or Version, Does anyone know some example of using versioned_object and version? Thanks in advance Mahdi Asgari --- ## Post #2 by @ian.mcnicoll Hi Mahdi, SELECT v/commit\_audit/committer/name, v/commit\_audit/time\_committed/value, v/data/uid, v/data/time\_created, c FROM EHR e \[ehr\_id/value = 'ecfe6e6e\-8868\-4fc6\-8db8\-def71cb8a250'\] CONTAINS VERSION v CONTAINS COMPOSITION c\[openEHR\-EHR\-COMPOSITION\.encounter\.v1\] should return commit \_audit and versioned\_object attributes for all Encounter compositions\. Ian Dr Ian McNicoll office \+44 \(0\)1536 414 994 fax \+44 \(0\)1536 516317 mobile \+44 \(0\)775 209 7859 skype ianmcnicoll ian\.mcnicoll@oceaninformatics\.com Clinical Modelling Consultant, Ocean Informatics, UK openEHR Clinical Knowledge Editor www\.openehr\.org/knowledge Honorary Senior Research Associate, CHIME, UCL BCS Primary Health Care www\.phcsg\.org --- ## Post #3 by @Mahdi_Asgari Thanks Ian Is the bellow EQL query correct for query in all versions of a composition ? SELECT v/commit\_audit/committer/name, v/commit\_audit/time\_committed/value, v/data/uid, v/data/time\_created, c FROM EHR e \[ehr\_id/value = 'ecfe6e6e\-8868\-4fc6\-8db8\-def71cb8a250'\] CONTAINS VERSIONED\_OBJECT vo CONTAINS VERSION v \[all\_versions\] CONTAINS COMPOSITION c\[openEHR\-EHR\-COMPOSITION\.encounter\.v1\] Where c/uid = '<hierobjectid>' --- ## Post #4 by @system Wow You are hot\! Sam --- ## Post #5 by @Heath_Frankel3 Yes, from memory this be about right, but the VERSIONED\_OBJECT part is redundant as it is not used anywhere in the query\. I notice you are specifying a HIER\_OBJECT\_ID as the COMPOSITION\.uid criteria\. Although it is not a specified and not a hard rule, it is recommended that a OBJECT\_VERSION\_ID is used in the COMPOSITION\.uid otherwise you have no way of getting the exact version of a composition when the composition is separated from the VERSION object\. Heath --- **Canonical:** https://discourse.openehr.org/t/aql-versionedobject-grammar/14186 **Original content:** https://discourse.openehr.org/t/aql-versionedobject-grammar/14186