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 |
dbonneau
Yak Posting Veteran
50 Posts |
Posted - 2013-07-07 : 01:08:18
|
Hi, I am trying to group by "GSLS" column from the data set from sub-query, but I get error saying Incorrect syntax near N. Could you tell me why this is wrong ? Thank you so much !SELECT GSLS, sum(CMNS) as CMNS( SELECT c.GSLS, CAST(CMNS as float) as CMNS FROM CS c, TR t where c.GACCT = t.ACCTNO) NGroup by GSLS |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-07-07 : 01:32:44
|
[code]SELECT GSLS, sum(CMNS) as CMNSFROM( SELECT c.GSLS, CAST(CMNS as float) as CMNS FROM CS c, TR t where c.GACCT = t.ACCTNO) NGroup by GSLS[/code]you can simply do[code]SELECT c.GSLS, SUM(CAST(CMNS as float)) as CMNS FROM CS c, TR twhere c.GACCT = t.ACCTNOGROUP BY c.GLSL[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
dbonneau
Yak Posting Veteran
50 Posts |
Posted - 2013-07-07 : 10:43:51
|
quote: Originally posted by khtan
SELECT GSLS, sum(CMNS) as CMNSFROM( SELECT c.GSLS, CAST(CMNS as float) as CMNS FROM CS c, TR t where c.GACCT = t.ACCTNO) NGroup by GSLS you can simply doSELECT c.GSLS, SUM(CAST(CMNS as float)) as CMNS FROM CS c, TR twhere c.GACCT = t.ACCTNOGROUP BY c.GLSL KH[spoiler]Time is always against us[/spoiler]
Thank you so much ! |
|
|
|
|
|
|
|