Jump to content

Recommended Posts

I am new to this forum and very new to this SQL issue.
As you know Excel allows you to sort a set of data in ascending or descending order and through an ordered list.
And here begins my problem, ie I would like to know if it is possible to do this order through a SQL statement.
Sort ascendingly and descending I already know how to do but what I wanted, and it is shown in the example I attached, it was first to sort by field F58 in ascending order and then to sort by field F66 by the following list 'RR-CON, RR-COGP, RR -COCN, RR-COCS, RR-COGL, RR-COS '
I've got an example, with the VBA code that fetches me a table from the F58 and F66 values according to certain criteria, and then that data is only sorted by field F58, I'd like it to be sorted from the list above.
It's possible?
Many thanks
Jorge Cabral

Teste com SQL_V1 - ENG.xlsm

Share this post

Link to post
Share on other sites

You didn't say which database you're using, but at least in MySQL if you make that field an enum field, and define the values in the order in which you want them listed, then that's the order if you sort by that field.

Share this post

Link to post
Share on other sites

In conjunction with what justsomeguy said,

You'll be able to put the query into practice after you've enumerated your custom column with something like this

ORDER BY `products`.`product_category_id` DESC ,`naam` ASC

In case you wanted to alternate, I'm sure you could modify this to suit your needs.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...