Combining rows based on Job ID in SQL Server -


new sql working sql server. have query pulls information need perform analysis on group of clients based on how system set requires manual clean in excel before data becomes useful.

some job id's end s when when analysis @ job id whole , have spend lot of time in excel manually combining data together.

example query result

job id   labor expense  direct material 10067    400395.29      96614.25 10067s   143668         44148.22 10068    545100.79      127143.64 10068s   147009.89      33506.31 

what when query run combine rows s in job id ones without 1 line of data each job.

example

job id  labor expense   direct material 10067   544063.29       140762.47 10068   692110.68       160649.95 

does have ideas on how can alter query accomplish this?

try this:

select replace( job_id, 's', '' ) "job id",        sum (labor_expense) "labor expense",        sum (direct_material) "direct material"   yourtable group replace( job_id, 's', '' ) order replace( job_id, 's', '' )  

remember change columns accordingly since may not defined spaces or suggested underlines.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -