Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rollup to one record with same order number

Status
Not open for further replies.

ciarra41

Technical User
Sep 11, 2006
116
US
I have multiple rows with duplicate orders numbers and separate order types where as some are null and some are not. How can I roll these up into one record by order number and where there’s null it will pick the corresponding value that is not null for the same order number? It can be two are more instances like this.
 
here's the example;

employeecode Monday Tuesday Wednesday Thursday Friday Saturday Sunday
502025 Rostered NULL NULL NULL NULL NULL NULL
502025 NULL Rostered NULL NULL NULL NULL NULL
502025 NULL NULL Rostered NULL NULL NULL NULL
502025 NULL NULL NULL Rostered NULL NULL NULL
502025 NULL NULL NULL NULL Rostered NULL NULL


I would like it just have one row and it just looks like this:

employeecode Monday Tuesday Wednesday Thursday Friday Saturday Sunday
502025 Rostered Rostered Rostered Rostered Rostered NULL NULL

 
Would a grouping and a MAX be sufficient?

Code:
select [employeecode], Max([Monday]), Max([Tuesday]),Max([Wednesday]), Max([Thursday]), Max([Friday]), Max([Saturday]), Max([Sunday]) from <your_table> group by employeecode

(FYI: not really a DTS question, more a programming one - forum183)

soi là, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top