SQLTeam.com | Weblogs | Forums

Sql lower

Hello and thank you for reading my topic,
I'm currently a SQL student. I have been given a task and I am stuck.
Much appreciate any guidance

select
firstname,
lastname,
substr(firstname,1,4)||substr(lastname,1,2) as userid
from employees

(below is the result, my problem is I need the userid results to be in lower case. I'm aware of the select lower(userid ) where im stuck is how do Implement it into my query?

+-----------+----------+--------+
| FirstName | LastName | userid |
+-----------+----------+--------+
| Andrew    | Adams    | AndrAd |
| Nancy     | Edwards  | NancEd |
| Jane      | Peacock  | JanePe |
| Margaret  | Park     | MargPa |
| Steve     | Johnson  | StevJo |
| Michael   | Mitchell | MichMi |
| Robert    | King     | RobeKi |
| Laura     | Callahan | LaurCa |
+-----------+----------+--------+

tried and many other ways:

select
substr lower(firstname,1,4)||substr lower(lastname,1,2) as userid
from employees

(no such column) error

This is a SQL Server, not Oracle etc, site. SQL SERVER uses + and not || to concatenate strings.

At a guess the following looks logical:

lower(substr(firstname,1,4)) || lower(substr(lastname,1,2)) AS userid
1 Like

From what I'm told in class we are using SQLite. Am I in the wrong forum?

ThanK you Ifor ( lower(substr(firstname,1,4)) || lower(substr(lastname,1,2)) AS userid ) worked !