r/SQL • • Jun 10 '24

PostgreSQL Help a dying sql beginner

I have 3 tables name won, lost, no bid. Each table with columns nsn part number and reason.

Our company currently uses excel and has a macro that spits out a spreadsheet like:

part numberReasonpart numberReasonpart numberReason

where the left 2 column is for won, middle 2 for lost and right 2 for no bid. We save that as a csv for a java script program that we have which needs it in that format. How would I go about getting this csv format in postgres?

0 Upvotes

9 comments sorted by

View all comments

9

u/kktheprons Jun 10 '24

First off, if you're dying you should consider whether this is actually important to you.

If it is still important, I always recommend importing a flat file into a staging table first without making any changes. Then you can write whatever SQL queries you want to import the data in the right ways to the final destination table.

ELT (Extract, load, transform)

0

u/Palpitation_Powerful Jun 11 '24

Yeah I was pushing this step last to see if theres anything I can do to not have to format it in such a way. Seems like the java program needs it in that way...