Selasa, 03 Juni 2014

RE: [MS_AccessPros] Sorting with a union query

 

Robin,
 
Try:
 
SELECT Unit, [fLastName] & " " & [fFirstName] AS Resident, Phone
FROM Telephone
WHERE ResidentStatus=4
UNION ALL
SELECT Unit, [mLastName] & " " & [mFirstName], Phone
FROM Telephone
WHERE ResidentStatus=4
ORDER BY 2;
 
Duane Hookom MVP
MS Access

 
> To: MS_Access_Professionals@yahoogroups.com
> From: MS_Access_Professionals@yahoogroups.com
> Date: Wed, 4 Jun 2014 10:49:08 +1000
> Subject: [MS_AccessPros] Sorting with a union query
>
> I am attempting to make a union query that will provide an
> alphabetical listing of residents.
>
> The SQL is below. The error message says that I must use the same
> fields in the ORDER BY expression. That is not possible.
>
> Is there a way around my problem?
>
> There are more 'ResidentStatus' fields to include if I overcome the
> first problem.
>
> Many thanks,
>
> Robin Chapple
>
>
>
> SELECT Telephone.Unit, [fLastName] & " " & [fFirstName] AS Resident,
> Telephone.Phone
> FROM Telephone
> WHERE (((Telephone.ResidentStatus)=4))
> ORDER BY [fLastName] & " " & [fFirstName];
>
> UNION SELECT Telephone.Unit, [mLastName] & " " & [mFirstName] AS
> Resident, Telephone.Phone
> FROM Telephone
> WHERE (((Telephone.ResidentStatus)=4))
> ORDER BY [mLastName] & " " & [mFirstName];
>
>
>
> ------------------------------------
> Posted by: Robin Chapple <robinski@westnet.com.au>
> ------------------------------------
>
> Yahoo Groups Links
>
> <*> To visit your group on the web, go to:
> http://groups.yahoo.com/group/MS_Access_Professionals/
>
> <*> Your email settings:
> Individual Email | Traditional
>
> <*> To change settings online go to:
> http://groups.yahoo.com/group/MS_Access_Professionals/join
> (Yahoo! ID required)
>
> <*> To change settings via email:
> MS_Access_Professionals-digest@yahoogroups.com
> MS_Access_Professionals-fullfeatured@yahoogroups.com
>
> <*> To unsubscribe from this group, send an email to:
> MS_Access_Professionals-unsubscribe@yahoogroups.com
>
> <*> Your use of Yahoo Groups is subject to:
> https://info.yahoo.com/legal/us/yahoo/utos/terms/
>

__._,_.___

Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar