Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
divan
Posting Yak Master
153 Posts |
Posted - 2013-05-16 : 09:21:10
|
I have the following script statement Select ltrim(isnull(c1.fname1,''), + isnull(c1.init1,''), + isnull(c1.lname1) as physician, sum (m.premium) as Total_premiumfrom mntablegroup by Physician When I run the script I get the following errorInvalid column name..How can I group the result by Physician even though Physcian is not a column in the table.. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-05-16 : 09:31:32
|
repeat your concatenation in group by Too old to Rock'n'Roll too young to die. |
|
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-05-16 : 10:28:35
|
Or you can try this:[CODE]SELECT physician, SUM(premium) as Total_premium from (Select ltrim(isnull(c1.fname1,''), + isnull(c1.init1,''), + isnull(c1.lname1) as physician, m.premium from mntable) MN GROUP BY physician[/CODE] |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2013-05-16 : 10:49:05
|
Select ltrim(isnull(c1.fname1,''))+',' + isnull(c1.init1,'')+',' + isnull(c1.lname1) as physician, sum (m.premium) as Total_premiumfrom mntablegroup by ltrim(isnull(c1.fname1,''))+','+isnull(c1.init1,'')+','+isnull(c1.lname1)CheersMIK |
|
|
|
|
|
|
|