troubleshooting Question

SQL Some row data in table A, to be fixed order columns in table B

Avatar of Mohammad Alsolaiman
Mohammad AlsolaimanFlag for Saudi Arabia asked on
3 Comments1 Solution18 ViewsLast Modified:
I have payment table, contains these fields:
  • Id
  • BscNo
  • PaymentDate
  • FinCode
  • CodeType
  • Amount
Every employee, in additional to his basic salary, he has several allowances & several deductions, stored in paymentTable.
The attached excel sheet has two sheets. One contains paymentTable with a sample data of 4 employee's records (allowances & deduction) for each.
  The other sheet has the intended table I need to have.
I need to have the full data for each employee in one row.
For instance, the first employee has 9 allowances, and 6 deductions which is represented in paymentTable in 15 rows. I need to have all of these rows to be in one row, and each amount should be placed under its allow/deduction code (which is became the column name in the other table(extractedTable) see the second excel sheet.
The other thing is that I need to have these columns fixed. I mean for instance the allowance code 102 should be always column number 4 in the extractedTable, column number 5 in the extractedTable should have the name 105 always, and so on. Because I'm running this process monthly, and this a customer requirement. Even if the whole column is null, keep it in its same order in the table.
help me, please.

question 01.xlsx
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros