Concatenate in Group By ?

stepone

Registered User.
Local time
Today, 09:13
Joined
Mar 2, 2004
Messages
97
Hi,

I am running a Group By query and want to get one of the text fields to concatenate (rather than pick First or Last). So, for example, if the data looked like this ;

Code:
Project    Job         JobType          Cost
1            1            Red                45
2            1            Red                45
2            2            Blue               20

I want to get a single entry for each project, so the output from the query would read ;

Code:
Project   Job Type          SumOfCost      
1           Red                 45
2           Red & Blue       65

Alternatively, if it was possible to output the text 'Various' or similar anywhere there was more than one Job Type, that would also be an option, so the output would look as follows ;

Code:
Project   Job Type          SumOfCost      
1           Red                 45
2           Various       65

It seems like this should be straightforward, I am probably missing something simple !

Thanks in advance,
StepOne
 
select project
, iif(count(*)>1, "Various", Jobtype)
, sum(cost)
from yourtable
group by project

Would that work? I am not sure...
 

Users who are viewing this thread

Back
Top Bottom