Kamis, 14 April 2016

Re: [MS_AccessPros] Re: Order question in query.

 

Hi Kevin

tblGroupBooking GB

can also be written as:

tblGroupBooking As GB

WHERE
GB is an 'alias', nickname, abbreviation, etc -- instead of writing the tablename out each time ...

assume GB is short for GroupBooking ...

warm regards,
crystal

~ have an awesome day ~

On 4/14/2016 6:54 PM, 'zhaoliqingoffice@163.com' zhaoliqingoffice@163.com [MS_Access_Professionals] wrote:
Duane,
What does "GB" mean? Is there any online descriptions about how to use "GB"? Thanks.
Best Regards,
Kevin


 
Date: 2016-04-12 06:12
Subject: RE: [MS_AccessPros] Re: Order question in query.
 

Kevin, 
Apparently you want to find the earliest Checkin for the first 6 characters of the GroupCode and use this for sorting the group. 

You can use a subquery like:

SELECT tblGroupBooking.CheckIn, tblGroupBooking.GroupCode, 
(SELECT MIN(Checkin) from tblGroupBooking GB WHERE LEFT(GB.GroupCode,6) = LEFT(tblGroupBooking.GroupCode,6)) AS GroupCheckin
FROM tblGroupBooking;

I don't believe you can sort by the derived column in the query but think this might work to sort a report. If that doesn't work, you could replace the subquery with DMin().

Duane Hookom, MVP
MS Access


To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Tue, 12 Apr 2016 05:54:27 +0800
Subject: Re:[MS_AccessPros] Re: Order question in query.

Bill-
This is the result I want:
===tblGroupBooking====
Checkin        GroupCode
2016-May-01    abc001-A
2016-May-05    abc001-B
2016-May-08    abc001-C
2016-May-02    def002
2016-May-03    def003
                       
Best Regrds,
Kevin


Life has an uncanny way of responding to your need.
"wrmosca@comcast.net [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>,2016年4月12日 上午5:26写道:


 
Kevin

I'm not understanding what you mean by "they should stick together". The sort order should still work even though the group code is a little longer. 

What results are you getting now and what is your query?

Regards,
Bill Mosca, Founder - MS_Access_Professionals
Microsoft Office Access MVP
My nothing-to-do-with-Access blog



---In MS_Access_Professionals@yahoogroups.com, <zhaoliqingoffice@163.com> wrote :


Dear All,

Is the possible to get this done by query?

===tblGroupBooking====
Checkin        GroupCode
2016-May-01    abc001-A
2016-May-05    abc001-B
2016-May-08    abc001-C
2016-May-02    def002
2016-May-03    def003
                       

I want the check in to be the first order, and BroupCode the second order. But If the group code has the same prefix (e.g. abc001), then they should stick to one another. Is that possible? Or is there's any other way to make the outcome look like this? Thanks in advance.

Best Regards,
Kevin

 




__._,_.___

Posted by: crystal 8 <strive4peace2008@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)

.

__,_._,___

Tidak ada komentar:

Posting Komentar