Answer the question
In order to leave comments, you need to log in
How to count the number of values in top SQL?
There is MS SQL the table.
id, name, rate
We need to take the last 100 entries by id and find out how many people with a rating of 1,2,3,4 have a total of 25 values. And sort everything in descending order.
BEGIN TRANSACTION;
CREATE TABLE test(Id integer PRIMARY KEY, Name text, rate integer);
INSERT INTO test VALUES(1,'Tom',2);
INSERT INTO test VALUES(2,'Lucy',4);
INSERT INTO test VALUES(3,'Frank',5);
INSERT INTO test VALUES(4,'Jane',5);
INSERT INTO test VALUES(5,'Julia', 2);
INSERT INTO test VALUES(6,'Helena', 3);
INSERT INTO test VALUES(7,'Sarah', 2);
COMMIT;
SELECT * FROM test;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question