Jump to content
Server Maintenance This Week. ×

SQL "AS" statement


This topic is 3258 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi, I'm querying some results and would like to title the column (first row). I wrote my sql statement as follows but I'm only receiving the results without the column header:

ExecuteSQL("SELECT CustID AS ID , SerialLS AS Serial_Number, DateNTime AS Date, Operator AS Name WHERE SerialLS = ?"; "    "; ""; Serial_LS)

 

Am I doing something wrong? What I was hoping to get is:

ID           Serial_Number         Date                Name

123         J-804-KL                  4-22-2014      Joe Doe

654         M-465-NO                2-01-2015      Marry Jane

 

Instead what I get is:

123         J-804-KL                  4-22-2014      Joe Doe

654         M-465-NO                2-01-2015      Marry Jane

 

Link to comment
Share on other sites

Am I doing something wrong?

​Nope; AFAICT, that feature is not implemented in FQL. But since you're doing this within the calculation engine anyway, try

Let ( [
  tab = Char(9) ;
  headerRow = Substitute ( List ( "ID" ; "Serial_Number" ; "Date" ; "Name" ) ; ¶ ; tab ) ; 
  dataRows
    ExecuteSQL ( "
      SELECT CustID, SerialLS, DateNTime, Operator
      FROM UnspecifiedTable
      WHERE SerialLS = ?
      " ; tab ; "" ; Serial_LS
    )
  ] ;
  List ( headerRow ; dataRows )
)

Edited by eos
Link to comment
Share on other sites

Thank you eos, it works very well. Question, is there an easy way to have the header align with the data rows? I ask because the result that I'm now getting is something like:

ID           Serial_Number                      Date                Name

123         J-804-KL                4-22-2014      Joe Doe

654         M-465-NO              2-01-2015      Marry Jane

Link to comment
Share on other sites

EDIT: I guess you could try to fiddle with the number of tab stops in the header calculation and/or the FQL argument; but the only reliable way would IMO be to display the result in a field that has appropriate tab stops set.

Edited by eos
Link to comment
Share on other sites

This topic is 3258 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.