using this example query I need a csv file that has the header information in line 1, then body information in line(2) 2 onwards.
salesid,custaccount,customerref,deliveryname,email linenum,itemid,name,salesqty,salesprice,createddatetime
select
st.salesid, st.custaccount, st.customerref, st.deliveryname, st.email,
sl.linenum,sl.itemid,sl.name, sl.salesqty, sl.salesprice, sl.createddatetime
from salestable st
inner join salesline sl
on st.salesid = sl.salesid
where st.dataareaid like 'fr'
and st.salesid like '%'
and st.custaccount like '%'
and sl.itemid like '%'