Jump to content

JCabral

Recommended Posts

Hi
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

Link to comment
Share on other sites

  • 4 weeks later...

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.

Link to comment
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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...