Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

sort recordset by 2 fields

Participant ,
Aug 07, 2008 Aug 07, 2008

Copy link to clipboard

Copied

I am aware that if you would like to sort records by 2 fields, you list both fields separated by a comma after ORDER BY (i.e. ORDER BY Name, Date)

With the above code, the only way records will sort by Date is if they are identical other than by their date.

Now what if I would really like to do is first sort records that share a common Name value regardless of other field values and then sort by Date ( Something like "First ORDER BY Name which contains the value of "PC" and then ORDER BY Date DESC")

Can this be done?
TOPICS
Server side applications

Views

425
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 12, 2008 Aug 12, 2008

Copy link to clipboard

Copied

LATEST
You can use a CASE statement in the ORDER BY clause.

"aonefun" <webforumsuser@macromedia.com> wrote in message
news:g7fvjq$qgs$1@forums.macromedia.com...
>I am aware that if you would like to sort records by 2 fields, you list
>both
> fields separated by a comma after ORDER BY (i.e. ORDER BY Name, Date)
>
> With the above code, the only way records will sort by Date is if they are
> identical other than by their date.
>
> Now what if I would really like to do is first sort records that share a
> common Name value regardless of other field values and then sort by Date (
> Something like "First ORDER BY Name which contains the value of "PC" and
> then
> ORDER BY Date DESC")
>
> Can this be done?
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines