Reputation: 319
Good morning, Is it possible to concatenate 2 calculate fields into 1 column? For each month of the year I have 2 columns, 1 outputs sales amount & the other sales numbers for each month;
January_£ | January Cases
£8,123.00 | 100
What I would like to do is to concatenate these into 1 column;
January
100 - £8,123.00
I have tried many methods & can concatenate 2 standard fields but cant seem to get the format correct for calculated fields? Columns in query at present;
Sum(If(Month(b.CaseDate) = 1, b.CaseCommission, 0)) As January_£,
Sum(Month(b.CaseDate) = 1) As January,
And my latest effort which doesnt work but also doesn't error!
CONCAT(Sum(If(Month(b.CaseDate) = 1, b.CaseCommission, 0)),Sum(Month(b.CaseDate) = 1)0 As January,
If anyone can confirm its possible to achieve this I would appreciate it.
Regards
gary
Upvotes: 0
Views: 248
Reputation: 29081
this should work:
SELECT CONCAT(Sum(Month(b.CaseDate) = 1), '-',
Sum(If(Month(b.CaseDate) = 1, b.CaseCommission, 0)) ) AS January;
Upvotes: 2
Reputation: 13700
Try this
CONCAT(Sum(If(Month(b.CaseDate) = 1, b.CaseCommission, 0)),'-',
Sum(Month(b.CaseDate) = 1)) As January,
Upvotes: 1