January 21, 2019 at 5:15 am
Hi, CREATE TABLE Activations(
ID INT
,ActivityName VARCHAR(20)
,UserID INT
)
INSERT INTO Activations
(ActivityName,UserID)
VALUES ('Baseball', 10),('Soccer', 10), ('Baseball', 20),('Soccer', 20),('Baseball', 30),('Soccer', 40),('Baseball', 60),('Soccer', 70),('Baseball', 80),('Soccer', 90),
('Baseball', 100),('Soccer', 100),('Baseball', 110),('Soccer', 110)
I have this table with this data, I want a query that can extract Users that are only subscribed to only one Activity, either Baseball or Soccer
January 21, 2019 at 11:10 am
mediacommentry - Monday, January 21, 2019 5:15 AMHi,CREATE TABLE Activations(
ID INT
,ActivityName VARCHAR(20)
,UserID INT
)INSERT INTO Activations
(ActivityName,UserID)
VALUES ('Baseball', 10),('Soccer', 10), ('Baseball', 20),('Soccer', 20),('Baseball', 30),('Soccer', 40),('Baseball', 60),('Soccer', 70),('Baseball', 80),('Soccer', 90),
('Baseball', 100),('Soccer', 100),('Baseball', 110),('Soccer', 110)
I have this table with this data, I want a query that can extract Users that are only subscribed to only one Activity, either Baseball or Soccer
You could try something like: SELECT UserID
FROM Activations
GROUP BY UserID
HAVING COUNT(*) = 1
Sue
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply