using Switch

  • Thread starter Thread starter shank
  • Start date Start date
S

shank

I'm trying to use Switch in an Order By clause. But having problems with
DESC.

For example: COL="orderno_desc",GenKStock.OrderNo <--works fine
But: COL="orderno_desc",GenKStock.OrderNo DESC <-- cause an error missing
operator

How can I specify descending order?
thanks

ORDER BY Switch(COL="orderno_asc",GenKStock.OrderNo,
COL="title_asc",GenKTitles.Title, COL="artist_asc",GenKTitles.Artist,
COL="description_asc",GenKTitles.Description,
COL="orderno_desc",GenKStock.OrderNo, COL="title_desc",GenKTitles.Title,
COL="artist_desc",GenKTitles.Artist,
COL="description_desc",GenKTitles.Description);
 
You might need two Switch() columns: one for Ascending and one for
Descending. You final Switch() expression pair in the Ascending would be
True,1
This would render the first Switch() in-effective in the sorting since the
column would be all 1s. The second Switch() for descending values would then
take over.
 
Can you expand a bit on this? I've never used Switch.
I've tried this without success (just a thought on my part)....
==============
ORDER BY Switch(COL="orderno_asc", GenKStock.OrderNo, COL="title_asc",
GenKTitles.Title, COL="artist_asc", GenKTitles.Artist,
COL="description_asc", GenKStock.Description, COL="orderno_desc",
GenKStock.OrderNo & " DESC", COL="title_desc", GenKTitles.Title & " DESC",
COL="artist_desc", GenKTitles.Artist & " DESC", COL="description_desc",
GenKStock.Description & " DESC");
================
Are you suggesting 2 Switch statements in the ORDER BY clause? If so, I
still have to designate DESC in some fashion ... correct?

thanks!
 
==============
ORDER BY Switch(COL="orderno_asc", GenKStock.OrderNo, COL="title_asc",
GenKTitles.Title, COL="artist_asc", GenKTitles.Artist,
COL="description_asc", GenKStock.Description,true,1),
Switch( COL="orderno_desc", GenKStock.OrderNo, COL="title_desc",
GenKTitles.Title,
COL="artist_desc", GenKTitles.Artist , COL="description_desc",
GenKStock.Description ,true,1) DESC;
================
 
Back
Top