Ask a Question related to ASP Database, Design and Development.
-
Bob Barrows #1
Re: sorting queries
You will need to create a sorting table with two columns: Category and Rank.
Enter your categories into the table and enter the apropriate rank numbers.
Then join Items to this new table using the Category columns and order by
the Rank column.
Bob Barrows
Paul Sorrell wrote:> This is how I currently sort my query..........
>
> SELECT * FROM Items WHERE Availability = True ORDER By Category
> DESC, Price DESC
>
> These are my categories.........
>
> SideBySide
> Pair
> Hammergun
> UnderOver
> DoubleRifle
> Combination
> Collectible
> Auto
> Rifle
> Single
> Airgun
>
> My question is, can I sort the categories in any way other than
> ascending or descending?
> I want to order them as above.
>
> Thanks in advance
> Paul S
Bob Barrows Guest
-
Sorting array vs sorting paginated array
....pulling in a long list of photos in a gallery, and I have a sort function working within the pages of data fine. I need to bring it back out of... -
Queries
hi all, i am using the tutorial: Creating Dynamic Playlist and able to play it correctly, when i open the swf file and i observe that there is 6... -
Queries of Queries
Hi, I am trying to combine two queries. The first is a basic query of a table in the database. <CFQUERY NAME="getStores"... -
Queries Of Queries Single Quote Problem
When using queries of queries I'm having the following issue. Select Company_ID From qry_MyQuery Where Company_NM = 'MyString''s' <----... -
ASP.net Queries
Hi Please suggest the solutions for the following questions in asp.net. 1) Is there any Mask edit control in asp.net?. If not possible can... -
Tom B #2
Re: sorting queries
There is no order to your categories, so how could a computer sort them like
that? If you gave me that list on a piece of paper and asked me to sort
them, I can guarantee that I would never have come up with that order.
Anyway, enough of my snotty comments.
I assume that your Categories are in a separate table, add a field for the
order that the category should be sorted by.
tblCategories
CategoryID int
Title varchar(50)
SortOrder int
Example data
CategoryID Title SortOrder
1 Pair 2
2 SideBySide 1
3 Hammergun 3
"Paul Sorrell" <egguns@eggunsNOSPAM.demon.co.uk> wrote in message
news:bfmrlo$47k$1$8300dec7@news.demon.co.uk...or> This is how I currently sort my query..........
>
> SELECT * FROM Items WHERE Availability = True ORDER By Category DESC,
> Price DESC
>
> These are my categories.........
>
> SideBySide
> Pair
> Hammergun
> UnderOver
> DoubleRifle
> Combination
> Collectible
> Auto
> Rifle
> Single
> Airgun
>
> My question is, can I sort the categories in any way other than ascending> descending?
> I want to order them as above.
>
> Thanks in advance
> Paul S
>
>
Tom B Guest
-
Paul Sorrell #3
Re: sorting queries
You have hit the nail on the head, I do not have a separate table for
categories.
I understand the concept but need a quick and easy fix for what alreadt
exists.
Is there no way I can call one category after another without a separate
table.
Something like
select * from items where category = sidebyside then pair then hammergun
etc.....
--
Thank you,
Paul Sorrell
[url]http://www.egguns.demon.co.uk[/url]
"Tom B" <shuckle@hotmail.com> wrote in message
news:udG3ZzVUDHA.1712@TK2MSFTNGP11.phx.gbl...like> There is no order to your categories, so how could a computer sort themascending> that? If you gave me that list on a piece of paper and asked me to sort
> them, I can guarantee that I would never have come up with that order.
>
> Anyway, enough of my snotty comments.
>
> I assume that your Categories are in a separate table, add a field for the
> order that the category should be sorted by.
>
> tblCategories
> CategoryID int
> Title varchar(50)
> SortOrder int
>
> Example data
>
> CategoryID Title SortOrder
> 1 Pair 2
> 2 SideBySide 1
> 3 Hammergun 3
>
> "Paul Sorrell" <egguns@eggunsNOSPAM.demon.co.uk> wrote in message
> news:bfmrlo$47k$1$8300dec7@news.demon.co.uk...> > This is how I currently sort my query..........
> >
> > SELECT * FROM Items WHERE Availability = True ORDER By Category DESC,
> > Price DESC
> >
> > These are my categories.........
> >
> > SideBySide
> > Pair
> > Hammergun
> > UnderOver
> > DoubleRifle
> > Combination
> > Collectible
> > Auto
> > Rifle
> > Single
> > Airgun
> >
> > My question is, can I sort the categories in any way other than> or>> > descending?
> > I want to order them as above.
> >
> > Thanks in advance
> > Paul S
> >
> >
>
Paul Sorrell Guest
-
Mark Schupp #4
Re: sorting queries
What DBMS?
--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
[email]mschupp@ielearning.com[/email]
[url]http://www.ielearning.com[/url]
714.637.9480 x17
"Paul Sorrell" <egguns@eggunsNOSPAM.demon.co.uk> wrote in message
news:bfn1cm$dju$1$8300dec7@news.demon.co.uk...the> You have hit the nail on the head, I do not have a separate table for
> categories.
> I understand the concept but need a quick and easy fix for what alreadt
> exists.
>
> Is there no way I can call one category after another without a separate
> table.
>
> Something like
> select * from items where category = sidebyside then pair then hammergun
> etc.....
> --
>
> Thank you,
> Paul Sorrell
> [url]http://www.egguns.demon.co.uk[/url]
>
>
> "Tom B" <shuckle@hotmail.com> wrote in message
> news:udG3ZzVUDHA.1712@TK2MSFTNGP11.phx.gbl...> like> > There is no order to your categories, so how could a computer sort them> > that? If you gave me that list on a piece of paper and asked me to sort
> > them, I can guarantee that I would never have come up with that order.
> >
> > Anyway, enough of my snotty comments.
> >
> > I assume that your Categories are in a separate table, add a field forDESC,> > order that the category should be sorted by.
> >
> > tblCategories
> > CategoryID int
> > Title varchar(50)
> > SortOrder int
> >
> > Example data
> >
> > CategoryID Title SortOrder
> > 1 Pair 2
> > 2 SideBySide 1
> > 3 Hammergun 3
> >
> > "Paul Sorrell" <egguns@eggunsNOSPAM.demon.co.uk> wrote in message
> > news:bfmrlo$47k$1$8300dec7@news.demon.co.uk...> > > This is how I currently sort my query..........
> > >
> > > SELECT * FROM Items WHERE Availability = True ORDER By Category> ascending> > > Price DESC
> > >
> > > These are my categories.........
> > >
> > > SideBySide
> > > Pair
> > > Hammergun
> > > UnderOver
> > > DoubleRifle
> > > Combination
> > > Collectible
> > > Auto
> > > Rifle
> > > Single
> > > Airgun
> > >
> > > My question is, can I sort the categories in any way other than>> > or> >> > > descending?
> > > I want to order them as above.
> > >
> > > Thanks in advance
> > > Paul S
> > >
> > >
> >
>
>
Mark Schupp Guest
-
Chris Hohmann #5
Re: sorting queries
"Paul Sorrell" <egguns@eggunsNOSPAM.demon.co.uk> wrote in message
news:bfn1cm$dju$1$8300dec7@news.demon.co.uk...alreadt> You have hit the nail on the head, I do not have a separate table for
> categories.
> I understand the concept but need a quick and easy fix for whatseparate> exists.
>
> Is there no way I can call one category after another without ahammergun> table.
>
> Something like
> select * from items where category = sidebyside then pair thenAssuming RDMS = SQL Server> etc.....
> --
>
> Thank you,
> Paul Sorrell
> [url]http://www.egguns.demon.co.uk[/url]
SELECT
*
FROM
Items
ORDER BY
CASE Category
WHEN 'SideBySide' THEN 0
WHEN 'Pair' THEN 1
WHEN 'HammerGun' THEN 2
WHEN 'UnderOver' THEN 3
WHEN 'DoubleRifle' THEN 4
WHEN 'Combination' THEN 5
WHEN 'Collectible' THEN 6
WHEN 'Auto' THEN 7
WHEN 'Rifle' THEN 8
WHEN 'Single' THEN 9
WHEN 'Airgun' THEN 10
END
Chris Hohmann Guest
-
Tom B #6
Re: sorting queries
Careful, I think he has guns.
"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:u%23EZg8XUDHA.2460@TK2MSFTNGP10.phx.gbl...order?> Quick and easy?!?!?
> Don't do things quick and easy. Do them right!!
>
> Tell me: what is so slow and hard about creating a 2-column table with,
> what, 10 rows of data? If that takes you any longer than 10 minutes you
> should be really ashamed of yourself! Add another 30 seconds to add a join
> statement to your query, and you have a solution in less than 11 minutes!
> This isn't quick and easy???
>
> Why is this the right way to do it? Why not use the clever solution that
> Chris provided?
> 1. Performance - while Chris's solution will work, it won't allow any
> indexes to be used to sort your data, leading to poor query performance
> 2. Re-use - is this the only query that will need to use this sort order?
> Are you sure? Do you want to reproduce that CASE statement every time you
> need this sort order? And what about if you need to modify that sortusing> Are you going to remember every place you used that CASE statement? Is> a separate ranking table starting to seem less slow and hard?
>
> Bob Barrows
>
> Paul Sorrell wrote:>> > You have hit the nail on the head, I do not have a separate table for
> > categories.
> > I understand the concept but need a quick and easy fix for what
> > alreadt exists.
> >
> > Is there no way I can call one category after another without a
> > separate table.
> >
> > Something like
> > select * from items where category = sidebyside then pair then
> > hammergun etc.....
> >
> > "Tom B" <shuckle@hotmail.com> wrote in message
> > news:udG3ZzVUDHA.1712@TK2MSFTNGP11.phx.gbl...> >> There is no order to your categories, so how could a computer sort
> >> them like that? If you gave me that list on a piece of paper and
> >> asked me to sort them, I can guarantee that I would never have come
> >> up with that order.
> >>
> >> Anyway, enough of my snotty comments.
> >>
> >> I assume that your Categories are in a separate table, add a field
> >> for the order that the category should be sorted by.
> >>
> >> tblCategories
> >> CategoryID int
> >> Title varchar(50)
> >> SortOrder int
> >>
> >> Example data
> >>
> >> CategoryID Title SortOrder
> >> 1 Pair 2
> >> 2 SideBySide 1
> >> 3 Hammergun 3
> >>
> >> "Paul Sorrell" <egguns@eggunsNOSPAM.demon.co.uk> wrote in message
> >> news:bfmrlo$47k$1$8300dec7@news.demon.co.uk...
> >>> This is how I currently sort my query..........
> >>>
> >>> SELECT * FROM Items WHERE Availability = True ORDER By Category
> >>> DESC, Price DESC
> >>>
> >>> These are my categories.........
> >>>
> >>> SideBySide
> >>> Pair
> >>> Hammergun
> >>> UnderOver
> >>> DoubleRifle
> >>> Combination
> >>> Collectible
> >>> Auto
> >>> Rifle
> >>> Single
> >>> Airgun
> >>>
> >>> My question is, can I sort the categories in any way other than
> >>> ascending or descending?
> >>> I want to order them as above.
> >>>
> >>> Thanks in advance
> >>> Paul S
>
>
Tom B Guest
-
Bob Barrows #7
Re: sorting queries
Bob Barrows wrote:
<snip>
I want to apologize for the tone of this reply (I stand by its content). I
regret any unintended slight to Chris who was merely attempting to answer
the question given. I will say again that his solution was, indeed, clever.
Bob
Bob Barrows Guest
-
John Beschler #8
Re: sorting queries
OK, now I'm confused. When I first saw Chris' reply I
thought to myself, that won't work, so I tried it and it
does (as you all already know).
However, I'm stumped as to why. The ORDER BY Clause (as I
understand it) takes column names as parameters:
I.E. ORDER BY LastName
Or, it can use the position of the column in the SELECT
statement:
I.E. SELECT Lastname, Firstname FROM MYTable ORDER BY 1
Chris' statement doesn't seem to follow either of those
rules.
Can one of you SQL experts explain this to me?
SELECT
*
FROM
Items
ORDER BY
CASE Category
WHEN 'SideBySide' THEN 0
WHEN 'Pair' THEN 1
WHEN 'HammerGun' THEN 2
WHEN 'UnderOver' THEN 3
WHEN 'DoubleRifle' THEN 4
WHEN 'Combination' THEN 5
WHEN 'Collectible' THEN 6
WHEN 'Auto' THEN 7
WHEN 'Rifle' THEN 8
WHEN 'Single' THEN 9
WHEN 'Airgun' THEN 10
END
John Beschler Guest
-
John Beschler #9
Re: sorting queries
Thanks Bob. That one really blew my mind!
content of that>-----Original Message-----
>A virtual column is created by the CASE statement. TheIt's as if you put>column is determined by the output of the CASE statement.I>the CASE statement into your SELECT clause like this:
>
>SELECT
>*,
>CASE Category
>WHEN 'SideBySide' THEN 0
>WHEN 'Pair' THEN 1
>WHEN 'HammerGun' THEN 2
>WHEN 'UnderOver' THEN 3
>WHEN 'DoubleRifle' THEN 4
>WHEN 'Combination' THEN 5
>WHEN 'Collectible' THEN 6
>WHEN 'Auto' THEN 7
>WHEN 'Rifle' THEN 8
>WHEN 'Single' THEN 9
>WHEN 'Airgun' THEN 10
>END As Rank
>FROM
>Items
>ORDER BY Rank
>
>HTH,
>Bob Barrows
>
>
>John Beschler wrote:>> OK, now I'm confused. When I first saw Chris' reply I
>> thought to myself, that won't work, so I tried it and it
>> does (as you all already know).
>>
>> However, I'm stumped as to why. The ORDER BY Clause (as>>> understand it) takes column names as parameters:
>> I.E. ORDER BY LastName
>> Or, it can use the position of the column in the SELECT
>> statement:
>> I.E. SELECT Lastname, Firstname FROM MYTable ORDER BY 1
>>
>> Chris' statement doesn't seem to follow either of those
>> rules.
>>
>> Can one of you SQL experts explain this to me?
>>
>> SELECT
>> *
>> FROM
>> Items
>> ORDER BY
>> CASE Category
>> WHEN 'SideBySide' THEN 0
>> WHEN 'Pair' THEN 1
>> WHEN 'HammerGun' THEN 2
>> WHEN 'UnderOver' THEN 3
>> WHEN 'DoubleRifle' THEN 4
>> WHEN 'Combination' THEN 5
>> WHEN 'Collectible' THEN 6
>> WHEN 'Auto' THEN 7
>> WHEN 'Rifle' THEN 8
>> WHEN 'Single' THEN 9
>> WHEN 'Airgun' THEN 10
>> END
>
>.
>John Beschler Guest
-
Chris Hohmann #10
Re: sorting queries
"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:%23SD1PBeUDHA.2272@TK2MSFTNGP11.phx.gbl...content). I> Bob Barrows wrote:
> <snip>
>
> I want to apologize for the tone of this reply (I stand by itsanswer> regret any unintended slight to Chris who was merely attempting toclever.> the question given. I will say again that his solution was, indeed,No offense taken. In fact, I should have included a disclaimer that I>
> Bob
>
>
was not advocating this method for general use. It was in response to "I
understand the concept but need a quick and easy fix for what
alreadt[sic] exists." The one thing I will add to your general (and
better) solution is that Paul may want to a string instead of numbers
for the rank column. A numeric column can bite you in the ass later on
when you need to move a record in between the items ranked 1 and 2.
HTH-
Chris
Chris Hohmann Guest
-
Chris Hohmann #11
Re: sorting queries
That should read "Paul may want to USE a string..."
Chris Hohmann Guest
-
Bob Barrows #12
Re: sorting queries
Chris Hohmann wrote:
Sorry, but that went right over my head ... :-)> That should read "Paul may want to USE a string..."
What should read "Paul may want to USE a string..."?
Bob
Bob Barrows Guest
-
Paul Sorrell #13
Re: sorting queries
What is meant
Assuming RDMS = SQL Server?
Mine is an Access database, is this the reason why I cant make it work?
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in
query expression 'CASE Category WHEN 'SideBySide' THEN 0 WHEN 'Pair' THEN 1
WHEN 'HammerGun' THEN 2 WHEN 'UnderOver' THEN 3 WHEN 'DoubleRifle' THEN 4
WHEN 'Combination' THEN 5 WHEN 'Collectible' THEN 6 WHEN 'Auto' THEN 7 WHEN
'Rifle' THEN 8 WHEN 'Single' THEN 9 WHEN 'Airg'.
/gunshop/StockListPrintOut.asp, line 31
Here is my code.............
<%Set AllItems = Connect.Execute(_
"SELECT *
CASE Category
WHEN 'SideBySide' THEN 0
WHEN 'Pair' THEN 1
WHEN 'HammerGun' THEN 2
WHEN 'UnderOver' THEN 3
WHEN 'DoubleRifle' THEN 4
WHEN 'Combination' THEN 5
WHEN 'Collectible' THEN 6
WHEN 'Auto' THEN 7
WHEN 'Rifle' THEN 8
WHEN 'Single' THEN 9
WHEN 'Airgun' THEN 10
END As Rank
FROM
Items
ORDER BY Rank, Price DESC ")%>
"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:urBi2RfUDHA.1872@TK2MSFTNGP12.phx.gbl...put> A virtual column is created by the CASE statement. The content of that
> column is determined by the output of the CASE statement. It's as if you> the CASE statement into your SELECT clause like this:
>
> SELECT
> *,
> CASE Category
> WHEN 'SideBySide' THEN 0
> WHEN 'Pair' THEN 1
> WHEN 'HammerGun' THEN 2
> WHEN 'UnderOver' THEN 3
> WHEN 'DoubleRifle' THEN 4
> WHEN 'Combination' THEN 5
> WHEN 'Collectible' THEN 6
> WHEN 'Auto' THEN 7
> WHEN 'Rifle' THEN 8
> WHEN 'Single' THEN 9
> WHEN 'Airgun' THEN 10
> END As Rank
> FROM
> Items
> ORDER BY Rank
>
> HTH,
> Bob Barrows
>
>
> John Beschler wrote:>> > OK, now I'm confused. When I first saw Chris' reply I
> > thought to myself, that won't work, so I tried it and it
> > does (as you all already know).
> >
> > However, I'm stumped as to why. The ORDER BY Clause (as I
> > understand it) takes column names as parameters:
> > I.E. ORDER BY LastName
> > Or, it can use the position of the column in the SELECT
> > statement:
> > I.E. SELECT Lastname, Firstname FROM MYTable ORDER BY 1
> >
> > Chris' statement doesn't seem to follow either of those
> > rules.
> >
> > Can one of you SQL experts explain this to me?
> >
> > SELECT
> > *
> > FROM
> > Items
> > ORDER BY
> > CASE Category
> > WHEN 'SideBySide' THEN 0
> > WHEN 'Pair' THEN 1
> > WHEN 'HammerGun' THEN 2
> > WHEN 'UnderOver' THEN 3
> > WHEN 'DoubleRifle' THEN 4
> > WHEN 'Combination' THEN 5
> > WHEN 'Collectible' THEN 6
> > WHEN 'Auto' THEN 7
> > WHEN 'Rifle' THEN 8
> > WHEN 'Single' THEN 9
> > WHEN 'Airgun' THEN 10
> > END
>
Paul Sorrell Guest
-
Bob Barrows #14
Re: sorting queries
Yes. Access does not have a CASE statement. Instead, you will need to use a
whole bunch of nested Iif statements (not my idea of "quick and easy"
<wink> ):
ORDER BY IIF(Category = 'SideBySide',0,IIF(Category = Pair,1,IIF...))
HTH,
Bob Barrows
Paul Sorrell wrote:> What is meant
> Assuming RDMS = SQL Server?
> Mine is an Access database, is this the reason why I cant make it
> work?
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
>
> [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
> operator) in query expression 'CASE Category WHEN 'SideBySide' THEN 0
> WHEN 'Pair' THEN 1 WHEN 'HammerGun' THEN 2 WHEN 'UnderOver' THEN 3
> WHEN 'DoubleRifle' THEN 4 WHEN 'Combination' THEN 5 WHEN
> 'Collectible' THEN 6 WHEN 'Auto' THEN 7 WHEN 'Rifle' THEN 8 WHEN
> 'Single' THEN 9 WHEN 'Airg'.
>
> /gunshop/StockListPrintOut.asp, line 31
>
> Here is my code.............
>
> <%Set AllItems = Connect.Execute(_
> "SELECT *
> CASE Category
> WHEN 'SideBySide' THEN 0
> WHEN 'Pair' THEN 1
> WHEN 'HammerGun' THEN 2
> WHEN 'UnderOver' THEN 3
> WHEN 'DoubleRifle' THEN 4
> WHEN 'Combination' THEN 5
> WHEN 'Collectible' THEN 6
> WHEN 'Auto' THEN 7
> WHEN 'Rifle' THEN 8
> WHEN 'Single' THEN 9
> WHEN 'Airgun' THEN 10
> END As Rank
> FROM
> Items
> ORDER BY Rank, Price DESC ")%>
>
>
> "Bob Barrows" <reb_01501@yahoo.com> wrote in message
> news:urBi2RfUDHA.1872@TK2MSFTNGP12.phx.gbl...>> A virtual column is created by the CASE statement. The content of
>> that column is determined by the output of the CASE statement. It's
>> as if you put the CASE statement into your SELECT clause like this:
>>
>> SELECT
>> *,
>> CASE Category
>> WHEN 'SideBySide' THEN 0
>> WHEN 'Pair' THEN 1
>> WHEN 'HammerGun' THEN 2
>> WHEN 'UnderOver' THEN 3
>> WHEN 'DoubleRifle' THEN 4
>> WHEN 'Combination' THEN 5
>> WHEN 'Collectible' THEN 6
>> WHEN 'Auto' THEN 7
>> WHEN 'Rifle' THEN 8
>> WHEN 'Single' THEN 9
>> WHEN 'Airgun' THEN 10
>> END As Rank
>> FROM
>> Items
>> ORDER BY Rank
>>
>> HTH,
>> Bob Barrows
>>
>>
>> John Beschler wrote:>>> OK, now I'm confused. When I first saw Chris' reply I
>>> thought to myself, that won't work, so I tried it and it
>>> does (as you all already know).
>>>
>>> However, I'm stumped as to why. The ORDER BY Clause (as I
>>> understand it) takes column names as parameters:
>>> I.E. ORDER BY LastName
>>> Or, it can use the position of the column in the SELECT
>>> statement:
>>> I.E. SELECT Lastname, Firstname FROM MYTable ORDER BY 1
>>>
>>> Chris' statement doesn't seem to follow either of those
>>> rules.
>>>
>>> Can one of you SQL experts explain this to me?
>>>
>>> SELECT
>>> *
>>> FROM
>>> Items
>>> ORDER BY
>>> CASE Category
>>> WHEN 'SideBySide' THEN 0
>>> WHEN 'Pair' THEN 1
>>> WHEN 'HammerGun' THEN 2
>>> WHEN 'UnderOver' THEN 3
>>> WHEN 'DoubleRifle' THEN 4
>>> WHEN 'Combination' THEN 5
>>> WHEN 'Collectible' THEN 6
>>> WHEN 'Auto' THEN 7
>>> WHEN 'Rifle' THEN 8
>>> WHEN 'Single' THEN 9
>>> WHEN 'Airgun' THEN 10
>>> END
Bob Barrows Guest
-
Chris Hohmann #15
Re: sorting queries
news:OBkPewgUDHA.1956@TK2MSFTNGP10.phx.gbl
Chris Hohmann Guest
-
Bob Barrows #16
Re: sorting queries
Chris Hohmann wrote:
Ah - I wonder why I never got this message...> news:OBkPewgUDHA.1956@TK2MSFTNGP10.phx.gbl
As to your point, can use the old programmer's trick of initially numbering
the ranks by 10: 10,20,30 ...
I usually just renumber them when the number of rows is this small.
Bob
Bob Barrows Guest
-
Chris Hohmann #17
Re: sorting queries
"Paul Sorrell" <egguns@eggunsNOSPAM.demon.co.uk> wrote in message
news:bfpfq4$oi$1$830fa78d@news.demon.co.uk...work?> What is meant
> Assuming RDMS = SQL Server?
> Mine is an Access database, is this the reason why I cant make it
Yes. When posting a database related question, it is often helpful to
indicate what database and version you are using. For Access you will
need to use IIF/SWITCH.
SELECT
..
..
..
ORDER BY
SWITCH
(
Category="SideBySide",0
Category="Pair",1
..
..
..
)
HTH
-Chris
Chris Hohmann Guest
-
Bob Barrows #18
Re: sorting queries
Aargh! I forgot about SWITCH! SWITCH will probably be easier than nested
IIF's
ORDER BY Switch(Category = 'SideBySide',0,Category = 'Pair',1,...)
Bob Barrows
Chris Hohmann wrote:> "Paul Sorrell" <egguns@eggunsNOSPAM.demon.co.uk> wrote in message
> news:bfpfq4$oi$1$830fa78d@news.demon.co.uk...>>> What is meant
>> Assuming RDMS = SQL Server?
>> Mine is an Access database, is this the reason why I cant make it
>> work?
> Yes. When posting a database related question, it is often helpful to
> indicate what database and version you are using. For Access you will
> need to use IIF/SWITCH.
>
> SELECT
> .
> .
> .
> ORDER BY
> SWITCH
> (
> Category="SideBySide",0
> Category="Pair",1
> .
> .
> .
> )
>
> HTH
> -Chris
Bob Barrows Guest
-
Paul Sorrell #19
Re: sorting queries
Hooray,
Thanks all thats perfect.
(anyone want to buy a gun?)
paul.
"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:utocmbiUDHA.2284@TK2MSFTNGP09.phx.gbl...> Aargh! I forgot about SWITCH! SWITCH will probably be easier than nested
> IIF's
>
> ORDER BY Switch(Category = 'SideBySide',0,Category = 'Pair',1,...)
>
> Bob Barrows
>
> Chris Hohmann wrote:>> > "Paul Sorrell" <egguns@eggunsNOSPAM.demon.co.uk> wrote in message
> > news:bfpfq4$oi$1$830fa78d@news.demon.co.uk...> >> >> What is meant
> >> Assuming RDMS = SQL Server?
> >> Mine is an Access database, is this the reason why I cant make it
> >> work?
> > Yes. When posting a database related question, it is often helpful to
> > indicate what database and version you are using. For Access you will
> > need to use IIF/SWITCH.
> >
> > SELECT
> > .
> > .
> > .
> > ORDER BY
> > SWITCH
> > (
> > Category="SideBySide",0
> > Category="Pair",1
> > .
> > .
> > .
> > )
> >
> > HTH
> > -Chris
>
Paul Sorrell Guest



Reply With Quote

