+ 4
What is the mistake in it?
SELECT * FROM Cakes LIMIT 2,ORDER BY calories; It shows there is a mistake near Limit...
7 odpowiedzi
+ 5
There should not be comma after 2
Order By should be before limit
and also there should be Limit 3
+ 5
i think you're talking about cakes exercise from SQL course :
so you missed one problem statement that it should be ordered ascending...
so the working could be like this :
SELECT * FROM cakes ORDER BY calories ASC LIMIT 2;
it's expected to display 2 rows . you shouldn't get 3 rows
The course exercise asks for 3 rows ..
SELECT * FROM cakes ORDER BY calories ASC LIMIT 3;
+ 3
Prashanth Kumar bro since on reading more lesson in SQL ,I understood adding DESC and ASC to ORDER BY ... thank you..
+ 2
A͢J thank you now it works...but why limit is 3 since in SQL it counts from 0..so 2 is enough I thought..but test case failed..
+ 2
Prashanth Kumar thank you now I got it...since ORDER BY itself arranges in ascending order by default ..I think ...is it necessary to add ASC to the statement?
+ 2
A͢J thank you I confused with index value in lesson ... now I got it
+ 1
Riya
You need top 3 records that is why Limit 3.
Count starts from 1 not 0
here you are not working with index.