Is there a way to bring variable values in where clause?
See link below in fiddles example. I want the code1 to be unique.
What I have tried:
Schema:
CREATE TABLE test (
id INT,
code1 varchar(5),
cityname varchar(24),
clue varchar(255)
);
INSERT INTO test (id, code1, cityname, clue) VALUES (1, 01, 'edison', 4567);
insert into test (id, code1, cityname, clue)
values(2, 01, 'highland park', 8765);
INSERT INTO test (id, code1, cityname, clue) VALUES (3, 02, 'franklin', 7865);
Query:
SELECT code1, cityname, count(*) as 'nofoftrsnsfers', sum(clue) FROM test
where code1 = 01
group by code1, cityname;