Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
SQL to select left character if a number but not a letter
Hello everyone,
I have a field in a table that consists of both numbers and letters. I would like to have a SQL statement that will select the first character in that field and if it is greater than "2" then show the number otherwise show "0". The SQL I use now does that but if there is a letter as the first character access shows it as '#Error' but I would like it to show "0" if it is a letter or number less than 2. This is the SQL I have tried:
SELECT Iif(Left([myField],1)>2, Left([myField],1),"0")
FROM MyTable;
Can anyone please help with this SQL statement?
Thank you!
Max
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement