| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
|||
difficult pivot?hi!
for a pivot view in our project database i need to join two tables. table bills ---- customer_id project_id month year price table payments ---- customer_id month year payment desired result ---- customer_id project_id month year price payment desired example: customer 2 is participating in project 2 & 3. - payment should be equal in line 2 and 3. ---- row 1: 1 2 1 2006 0 300 row 2: 1 2 2 2006 1,000 500 row 3: 1 3 2 2006 150, 500 row 4: 1 2 3 2006 750 0 if i use the code below i always miss line 1 because there is no entry for the second table. of course not, [...]
SELECT customer_id, project_id, month, year, price, (SELECT price FROM bills WHERE bills.customer_id=payments.customer_id AND bills.month=payments.month AND bills.year=bills.year) FROM paymentsi didn't figure out how to solve that in access. - i know it would be easier in a stored procedure, though, do you have an idea to solve my gordian knot? cheers |
|
Be the first to answer this question! Click on the 'Post Reply' button below.
|
![]() |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|