Hi All,
I've an Excel application which queries a database table, and uses the results to populate a combo box.
However, the table has lots of duplicate values in it - I'd like one of each to appear only, hence a SELECT DISTINCT requirement. I'd also like to sort them in ascending order, so an ORDER BY clause is also needed.
However, the fields are text fields, and when I try to do this, I get the error that I can't do DISTINCT or ORDER BY on text fields.
How can I get around this in order to remove the duplicates and order them alphabetically? This is in VBA so as I understand it, it all needs to be done in a single SELECT statement to return the data.
My query is created dynamically, but essentially looks like this (in duplicated, unordered form):
I've an Excel application which queries a database table, and uses the results to populate a combo box.
However, the table has lots of duplicate values in it - I'd like one of each to appear only, hence a SELECT DISTINCT requirement. I'd also like to sort them in ascending order, so an ORDER BY clause is also needed.
However, the fields are text fields, and when I try to do this, I get the error that I can't do DISTINCT or ORDER BY on text fields.
How can I get around this in order to remove the duplicates and order them alphabetically? This is in VBA so as I understand it, it all needs to be done in a single SELECT statement to return the data.
My query is created dynamically, but essentially looks like this (in duplicated, unordered form):
Code:
SELECT
tblMobPageDictionary.Table_name,
tblMobPageDictionary.Field_name,
tblMobPageDictionary.Label
FROM
tblMobPageDictionary