
November 11th, 2004, 08:49 PM
|
 |
Contributing User
|
|
Join Date: Aug 2004
Posts: 130
 
Time spent in forums: 1 Day 14 h 14 m 36 sec
Reputation Power: 5
|
|
|
count of newly created usernames does not work properly
OK, Im supposed to create a query that makes a username for each employee (specs of username to follow) and shows each username and number of instances of that username (to see if each one is unique).
Specs for username
It should be composed of first 2 chars of first_name, then first 2 chars of last_name, and then last char of last_name.
Now I was able to create the usernames but have trouble displaying the number of each occurrence of a username. I have tried the following but this displays 2 same usernames each with a count of 1... which is not what i want:
Code:
select lower(substr(first_name,1,2) || substr(last_name,1,2) ||
substr(last_name,length(last_name),1)),
count(substr(first_name,1,2) || substr(last_name,1,2) ||
substr(last_name,length(last_name),1))
from employees
group by substr(first_name,1,2) || substr(last_name,1,2) ||
substr(last_name,length(last_name),1),
first_name, last_name
Your help is greatly appreciated 
|