Just put e.firstname in as one of the SELECTed fields, i.e.

SELECT DISTINCT t.employeeid, e.firstname + e.lastname AS name,
e.firstname

> -----Original Message-----
> From: Jim McAtee [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 23 January 2003 1:56 p.m.
> To: CF-Talk
> Subject: Query How-To
> 
> 
> How can I go about ordering the following query by first name?
> 
> <cfquery name="emp" datasource="#dsn#">
> SELECT DISTINCT(t.employeeid),
>        e.firstname + e.lastname AS name
> FROM transactions t
>      LEFT JOIN employees e ON t.employeeid = e.employeeid
> </cfquery>
> 
> The following query throws an error about a conflict between 
> the ORDER BY and
> DISTINCT.
> 
> <cfquery name="emp" datasource="#dsn#">
> SELECT DISTINCT(t.employeeid),
>        e.firstname + e.lastname AS name
> FROM transactions t
>      LEFT JOIN employees e ON t.employeeid = e.employeeid
> ORDER BY e.firstname
> </cfquery>
> 
> Thanks,
> Jim
> 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to