Skip to main content

Notifications

Power Automate - General Discussion
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Compare two SQL query results, create new columns and export to CSV

Posted on by
I have two different views on same on-prem SQL server/database.  Running two queries (Get Rows) to retrieve data from the views.
 
Both query results need to be compared based on a 'reference number' column.  This value is unique in the first query result, but there may be multiple rows with the same value in the second query results.
 
Will need to construct a single string, appending all column values from the second query result with the same reference number.  Eg. Query returns columns 'Date', 'CompanyName', 'Description'.  The string will be 'Date1 | CompanyA | DescriptionA | Date2 | CompanyB | DescriptionB...'
 
There will also be multiple columns in the second query result that will need to be summed.
 
Finally will need to create a csv with the following :
 
- All columns from first query result
- A new column, with the string described above, where reference number between the two queries match
- Multiple new columns with the sums described above, where reference number between the two queries match
 
I can create a CSV with query results just fine, but have no idea how to go about...everything else described above...
 
Originally performed all this processing in PowerApp, and just ran the flow to create csv based on post-processing data provided by Powerapp.  But the results were incomplete and supposedly this is common issue exporting from gallery...
Categories:

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,343

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard