Help! Anyone could help me with this Query?

The energy table shows the 2014 energy consumption and production of each U.S. state, measured in billions of BTU (British Thermal Unit). How many states produce more energy than they consume?
THANKS!!!

1 Like

Hi, welcome to the Forums.

Is there a link to a lesson?

What is your code so far? What exactly has you stuck? What have you tried?
Please post your formatted code.

1 Like

Hi @lisalisaj

I’ve just bumped against this question in the Practice section too. I used SELECT to view the table. It has 3 columns:
states TEXT
consumption INTEGER
production INTEGER

I’ve just started SQL and I’m a bit lost. Tried to at least get a list with all states where production is greater than consumption, but to no success. I wrote:

SELECT * FROM energy
WHERE production > consumption;

Link to the practice question here:
https://www.codecademy.com/practice/tracks/analyze-data-sql-query-data/modules/analyze-data-sql-learn-queries

Thanks!

I don’t see a practice question in that link…

Also, you cannot compare columns like that. Are the columns summed? averaged?

1 Like

Hi lisalisaj,

Thanks for replying,

That is all that question has … Indeed, columns cannot be compared like that. It does seem off, but I guess I can go on and continue the course without it.
Let’s leave it…

Thanks again for picking this up once more,

All the best!
Vlad