Without knowing what version of LDMS you are using.
If you have created a query then you can use it to create a report, from which you can then generate a CSV, if you use the columns to display then this should restrict the amount of data that is generated for you.
I am sure you could review the query you have created and get a SQL Query to do the job, but you may find the report output will give you what you need.
I hope that helps you get to the information you need
We are using 8.8 SP3.
Unfortunately it needs to be an SQL query as the code will be used to import to another database.(Software Organiser)