XQuery is an extension of XPath. Here's an example in XPath. These things are easiest to understand if we know the structure of your docs. Suppose I insert:
xdmp:document-insert("test.xml", <note><date-taken>2015-01-01</date-taken></note>) I could find the count of docs more than two years old like this: count(/note[fn:days-from-duration(fn:current-date() - date-taken) > (365 * 2)]) Sam Mefford Senior Engineer MarkLogic Corporation sam.meff...@marklogic.com Cell: +1 801 706 9731 www.marklogic.com<http://www.marklogic.com> This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation. ________________________________ From: general-boun...@developer.marklogic.com [general-boun...@developer.marklogic.com] on behalf of Ladner, Eric (Eric.Ladner) [eric.lad...@chevron.com] Sent: Thursday, August 24, 2017 2:24 PM To: MarkLogic Developer Discussion Subject: [MarkLogic Dev General] Noob query question.. I’m still rather new to MarkLogic and apparently have a lot to learn. When doing research on a proof of concept, I ran across a situation that would be trivial to solve in SQL, but I’m having problems wrapping my head around how to do that in XQuery. Or, is XQuery even the right place for this? Basically, the number of notes per subject for any note that’s less than two years old. If I was to do this in SQL, it’d look something like: select subject, count(*) from notes where date_taken > sysdate-(365*2) group by subject; There’s some additional WHERE clause stuff for filtering, but on average, the number of results shouldn’t be large. Any guidance on building up more complex queries like this? The documentation is semi-helpful, but the examples it gives for usage are usually very simplistic. Eric Ladner Systems Analyst eric.lad...@chevron.com<mailto:eric.lad...@chevron.com>
_______________________________________________ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general