I am very new to Oracle, While i am practicing some examples i encountered with the problem “invalid character (SQL-HY000)“.
Below are sample table and data that i used for my practice
CREATE TABLE games (
id INT NOT NULL PRIMARY KEY ,
city VARCHAR(20),
name VARCHAR(20)
);
INSERT INTO games(id,city,name) VALUES (2004,'Athens','football');
INSERT INTO games(id,city,name) VALUES (2008,'Beijing','cricket');
SELECT id, COUNT(*) over() as rowcount
FROM games g
where name='football'
GROUP BY CASE
WHEN name='football'
THEN g.name
END;
What is the invalid character in the select statement ?
Any help will be greatly appreciated
Because of the
CASEwithin theGROUP BY. Also,GROUP BYis not required, since you are already filtering thefootballrows in theWHEREclause:When you use an analytic function, such as
COUNT(*) OVER(), you don’t need to useGROUP BY. They serve different purposes.DEMO.