I’m assuming you’re using a “normal” DB like MySQL/PostgreSQL.
Select entries with common attributes (just search for the syntax to select rows based on attributes for your DB).
Utilise a PowerShell script/Shell script/Python/any other language you’re comfortable with to parse the output from the DB into a file.
I mentioned PowerShell since you want to create an excel file, and using objects (assigning attributes to said object) might be easier to handle writing to a file with, rather than using regex/awk if you’re using Shell (although that’s fun in its own way).
Write to file. PowerShell has modules to write to excel/csv, I don’t think a Shell script could do that as easily but you can definitely find a way (note that if you try using PowerShell on Linux, the modules I mentioned might not work).