I know this thread is old, but I just dealt with this today, and found a simpler method than the one that @mwra mentioned above. I’ll put it here for posterity.
Rather than dealing with any kind of export code, you can just use the attribute browser. Search for the notes that you want with the query, and add the attributes you are interested in exporting as columns. For example here is the attribute browser with a list of expenses that I’ve been tracking, with the date, description, and amount listed as columns in the attribute browser:
You can then export the current view by selecting File -> Export -> as Attribute Browser:
This exports the view in the (rather strange) format of a tab-delimited RTF file:
Open this file with TextEdit, and hit ⇧⌘T to convert it to plain text:
Save the plain-text document with a .tsv extension (for Tab-Separated Value). You can now open it with Excel, Numbers, Google Sheets, or what have you.