Some error occured while loading page for you. Please try again.
Sort 150 Discussions, By:
Please Login in order to post a comment
Here is Oracle solution from my HackerrankPractice repository:
COUNTRYCODE = 'USA'
AND POPULATION > 100000;
Feel free to ask if you have any questions :)
select * from city where population >10000 AND countrycode='USA';
see above query i have tried lots of time but i am not able to solve so plz help me
You have a typo: population >10000 instead of population >100000
select * from CITY where countrycode = 'USA' and population > 100000;
Can any one let me know how it is wrong?
I was equally frustrated...then I changed from Oracle to PLSQL and it worked..try doing that
Simple working query in Oracle (multi-line):
WHERE COUNTRYCODE = 'USA' AND POPULATION > 100000;
Reading the Editorial after successful submission...
Select all columns using the all-column wildcard (*).
No! No! And no!
Please, do not start beginner tutorials and exercises with wrong or bad practices.
This exercise is basic
SELECT * FROM CITY
WHERE COUNTRYCODE="USA" AND POPULATION>100000
Why is the (*) considered bad practice? I'm new to this.
TL;DR: It's bad style and you should not even start with it.
The SSF (Select 'Star' From) is a typical code smell. Usually done out of laziness of the writer. The problem here is that the order of columns can change over time given structural changes in the table. Using an explicit list of selected columns gives you better control over the expected result (and sequence of columns). Additionally, you can exactly define which set of columns instead of all (*) you'd like to have in the result.
Tools like SQL prompt offer you functionality to expand the wildcard into proper column names.
See here: https://documentation.red-gate.com/codeanalysis/best-practice-rules/bp005 for some ideas.
Also, if you are working with a big dataset you'll be using lots of memory to pull columns that you do not even need or will use.
select * from city where CountryCode='USA' AND population>100000;
it is easy query
I have tried SELECT*FROM CITY WHERE COUNTRYCODE='USA' AND POPULATION > 10000; multiple times and it doesn't work; eventhough the answers are correct!
it should be population > 100000 probly typos.
You have 10000, 10000 =! 100000
My initial query failed for oracle database and I was thrown aback, only for it to succeed when I changed the "&&" to "AND".
I am quite surprised because my PLSQL will accept "&&" and not "AND".
The failed statement:
SELECT * FROM CITY WHERE COUNTRYCODE = 'USA' && POPULATION > 100000;
City.jpg is not visible.
select * from city where countrycode = "USA" and population > 100000;
Why isn't this code working but it does when USA is written withing single quotes instead of the double quotes?
I thought that more than one characters had to be enclosed within double quotes! How am I wrong.
Pardon me if I sound silly, I am new to SQL.
bro add single bracket at place of double bracket
ex - "USA" wrong
Can we use IS statement instead of "="? I have tried but failed.