dimanche 12 février 2017

SQL: COUNT LENGTH OF DIGITS PER COLUMN PER ROW

Vote count: 0

I'm new in SQL and trying to complete the following assignment, I generated the following table:

CREATE table user (

user_id INT NOT NULL UNIQUE AUTO_INCREMENT,

user_phone_number INT,

user_city VARCHAR(32) NOT NULL,

PRIMARY KEY (user_id) );

And I'm being asked the following: number of users per length of the phone number (number of numeric digits)

I try the following:

SELECT LENGTH(user_phone_number) FROM user WHERE user is not null GROUP BY user_phone_number);

but if there are several users with the same phone number length it repeats them in several rows instead of providing the Total per length. Please help

asked 1 min ago

Let's block ads! (Why?)



SQL: COUNT LENGTH OF DIGITS PER COLUMN PER ROW

Aucun commentaire:

Enregistrer un commentaire