sql server - Get error on a query on a query? -


i have query

<cfquery datasource="intranet" name="getmaxstars">     select   top (1) ties emp_id, sum(execoffice_status) total_max         csereduxresponses     group emp_id     order total_max desc </cfquery >  <cfquery datasource="phonelist" name="getemployees">     select first_name, last_name, emp_id     employee </cfquery>  <!--- query of query join ---> <cfquery name="getemployeestars" dbtype="query">     select getemployees.first_name + ' ' + getemployees.last_name full_name, getmaxstars.total_max stars     getmaxstars, getemployees     getmaxstars.emp_id = getemployees.emp_id </cfquery> 

in query want max of emp_id in csereduxresonses table, want ouput full name of employee employee table has , how stars(execoffice_status) employee has. ouput this:

john doe 4

i keep getting error:

query of queries syntax error. encountered ". incorrect select list, incorrect select column, getemployees.emp_namefirst cannot followed '+'

the error occurred in c:\inetpub\wwwroot\webserver\win\test\cse_execoffice_newsletter.cfm: line 60

58 :
59 : 60 : 61 : select getemployees.emp_namefirst + ' ' + getemployees.emp_namelast full_name, getmaxstars.total_max [stars] 62 : getmaxstars, getemployees

looks it's either bug on concatenating aliases.

below sample:

<cfset myquery = querynew("column_1, column_2", "varchar, varchar")>  <cfloop index="i" from="1" to="5">     <cfset newrow = queryaddrow(myquery, 1)>         <cfset newcell = querysetcell(myquery, "column_1", i)>     <cfset newcell = querysetcell(myquery, "column_2", i)> </cfloop> <cfdump var="#myquery#" label="myquery">  <hr />  <cfquery name="qoq" dbtype="query">     select         [myquery].[column_1] column_1,         [myquery].[column_2] column_2     [myquery] </cfquery> <cfdump var="#qoq#" label="qoq">  <hr />  <cfquery name="qoq_new" dbtype="query">     select         [myquery].[column_1] column_1,         [myquery].[column_2] column_2,         ([myquery].[column_1] + ' ' + [myquery].[column_2]) stars     [myquery] </cfquery>  <cfdump var="#qoq_new#" label="qoq_new"> 

you can run code sample on http://cflive.net/ , see coldfusion gives error, railo doesn't.

guess won't work you.

edit: base on dan's link above, parenthesis around concatenated select column work:


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -