sqlcurious
asked on
Need help with sql coding
Project | PONum | PODesc
200078 3152000745 PTNumber
200078 3153000135 CANumber
200078 3153000235 CANumber
200090 3153000234 PTNumber
For the above give sample table, I should get a result as below: For every project number if there are multiple PONum, I need to consider only the first two and display them as PONum1(3152000745), PONum2 ,PODesc1 and PODesc2 resp.
ex the above table should show as below:
project | PONum1 | PODesc1 | PONum2 | PODesc2
200078 | 3152000745 | PTNumber | 3153000135 | CANumber
200090 | 3153000234 | PTNumber | |
Thanks!
Please note that the third PONumber for the first project number is ignored. only the first two are considered.
200078 3152000745 PTNumber
200078 3153000135 CANumber
200078 3153000235 CANumber
200090 3153000234 PTNumber
For the above give sample table, I should get a result as below: For every project number if there are multiple PONum, I need to consider only the first two and display them as PONum1(3152000745), PONum2 ,PODesc1 and PODesc2 resp.
ex the above table should show as below:
project | PONum1 | PODesc1 | PONum2 | PODesc2
200078 | 3152000745 | PTNumber | 3153000135 | CANumber
200090 | 3153000234 | PTNumber | |
Thanks!
Please note that the third PONumber for the first project number is ignored. only the first two are considered.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start by reading up on CTEs in SQL Server BOL. Let me know if you need a link.
ASKER
thnks
ASKER