Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Rustywater #1
Using DISTINCT wirh ORDER BY
Hi All,
This query results in a conflict.
<cfquery name="sellers" Datasource="#Application.datasource#">
select DISTINCT users.uid_user, full_name from users, member_types, user_roles
where users.uid_user=user_roles.uid_user and
user_roles.uid_role=member_types.uid_member_type and
member_types.is_committee=true
<cfif #session.sequence# is True>
order by first_name, last_name
<cfelse>
order by last_name, first_name
</cfif>
</cfquery>
The user_roles table can have multiple entries for a single user, hence the
use of distinct, but I still want to order the query results. The full_name,
last_name and first_name columns are all from the users table.
How can I do this given DISTINCT and ORDER BY conflict?
Rustywater Guest
-
SQL Distinct
I want to select distinct value from one field of the table and select rest of the corresponding fields accordingly. I have a table that has fields:... -
'distinct on' and 'order by' conflicts of interest
It has come up several times on the various postgresql lists that in order to get around the requirement of DISTINCT ON parameters matching the... -
need help on DISTINCT
Hi ALl, I need some help on DISTINCT in a query I'm trying to run. I have two tables which are linked. This is the query I use: SQL = "SELECT... -
SELECT DISTINCT + ORDER BY gives ERROR 145: ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
Following is my stored procedure. If I take the DISTINCT out then everything works fine. BUT I need the distinct because it returns duplicate... -
SELECT DISTINCT + ORDER BY gives ERROR 145: ORDER BY items mustappear in the select list if SELECT DISTINCT is specified.
Dan, You should be able to do this: SELECT Id, FaxID, ReceivedTime, Pages FROM ( SELECT DISTINCT .Id AS Id, -
MikerRoo #2
re: Using DISTINCT wirh ORDER BY
Try adding last_name and first_name to the select clause of the query.
MikerRoo Guest
-



Reply With Quote

