PC Review


Reply
Thread Tools Rate Thread

Anyone who can help my fried mind with this solution?

 
 
NY
Guest
Posts: n/a
 
      3rd May 2010

Dear all,

I am writing code about custom sorting tecniques. This code will appear
in my upcoming book. I explain two ways: one by using the switch function
and the other by using a lookup table. Although both solutions work as they
are supposed to, with respect to the sorting criterion (state), the records
WITHIN each state do not appear in the same exact order. I am fried to think
anymore at this point. I wrote too much code.

This is the custom sorting order using switch

SELECT *
FROM Qry_Conditions
WHERE STATE in ("NY","CA","TX")
ORDER BY
SWITCH(
[state]= 'NY', 1,
[state]= 'CA', 2,
[state] = 'TX', 3
)


This is the custom sorting order using a lookup table

SELECT * FROM Qry_Conditions
INNER JOIN tblS_State ON Qry_Conditions.state = tblS_State.State;

The tbls_State contains:
1 NY
2 CA
3 TX

If you want to download the database to play with the code, you can do that
here:
http://www.databasechannel.com/sampl...2007/data.html

Any suggestions will be highly appreciated.

My best
Pinda


 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      4th May 2010
On Mon, 3 May 2010 21:19:00 +0000 (UTC), NY wrote:

>I am writing code about custom sorting tecniques. This code will appear
>in my upcoming book. I explain two ways: one by using the switch function
>and the other by using a lookup table. Although both solutions work as they
>are supposed to, with respect to the sorting criterion (state), the records
>WITHIN each state do not appear in the same exact order.


I wouldn't expect them to. Access will display the records in whatever order
it finds convenient, based on the query plan and the disk storage order of the
records, unless you have a second sort field. Why would you *expect* unsorted
records to appear in sorted order?
--

John W. Vinson [MVP]
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Is my CPU FRIED???????? :( Please have a look at this! Wandering Windows Vista Hardware 1 29th Oct 2008 04:47 PM
Is it fried??? =?Utf-8?B?Uml0Y2hpZUpIaWNrcw==?= Windows XP General 2 9th May 2006 03:24 AM
What is fried? nobody@nowhere.net Processors 9 27th Aug 2005 02:17 AM
fried CPU Sam Horder DIY PC 10 25th Dec 2004 11:04 PM
Re: Fried CPU? rAD DIY PC 4 7th Sep 2003 11:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:19 PM.