JCabral Posted February 21, 2019 Share Posted February 21, 2019 HiI 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 More sharing options...
JCabral Posted March 16, 2019 Author Share Posted March 16, 2019 Any help? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 18, 2019 Share Posted March 18, 2019 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 More sharing options...
Funce Posted March 18, 2019 Share Posted March 18, 2019 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now