Below have XML code for Fetch Data from Tally.
<ENVELOPE>
<HEADER>
<TALLYREQUEST>ExportData</TALLYREQUEST>
</HEADER>
<BODY>
<EXPORTDATA>
<REQUESTDESC>
<REPORTNAME>StockSummary</REPORTNAME>
<STATICVARIABLES>
<SVCURRENTCOMPANY>Company-2</SVCURRENTCOMPANY>
<SVEXPORTFORMAT>$$SysName:HTML</SVEXPORTFORMAT>
<EXPLODEFLAG>YES</EXPLODEFLAG>
<ISITEMWISE>YES</ISITEMWISE>
</STATICVARIABLES>
</REQUESTDESC>
</EXPORTDATA>
</BODY>
</ENVELOPE>
It is not possible to get the sql query via this XML snippet. You would need to go into the Tally code, search for this report([Report:StockSummary]), and then find the collection within this report. Once you know the collection, you will be able to pick out individual fields from the collection using the following query:
select $Field1, $Field2 from Collection_Name
Hope this helps.