"How many tables are in the room?"
I find it useful to use multiple resources. For structure, these have been helpful:
へやにテーブル is enough because テーブル is in the へや and に conects them.
は would mark the theme; but the theme is not へやに but it''s the テーブル that is in the room. So へやにテーブルは...
が isn't suitable here because it's a marker of what is unknown and what is known information. The part before it is unknown and the part after it is known. The opposite is true for は: the part before it is known and the part after is unknown¹. So, let's analyze the two parts of this sentence:
へやにテーブル and いくつありますか
What are you looking for? The number of tables in the room or the existence of tables in the room? Of course, the number of tables. In other words, へやにテーブル is known information i.e. you already know that there are tables in room (or at least you imagine). What is unknown is いくつありますか i.e. you may know there are tables (and may even see it) but you haven't counted it.
Not sure if you know Spanish, but this thing of known/unknown information is well explained in this video: https://www.youtube.com/watch?v=LuwerftLyB4 (starts at 7:36).
I'm gonna leave this for reference since GabrielYuji96's comment is conceptually wrong.
「が」marks a "be-er" in this sentence, it can also mark "doer" with action verbs for example.
「いくつ」is an adverbial extension of the verb-question ～ありますか？
「部屋に」states the location in which you are interested.
「テーブルは」stresses the tables as a topic because you want to know the number of tables and not other items.
However, the English sentence "How many tables are in the room?" can be translated both ways:
「部屋にテーブルはいくつありますか？」"in the room, regarding tables, how many exists?" or "how many tables (and not other items) are in the room?"
「部屋にはテーブルがいくつありますか？」"speaking of the inside of the room, how many tables exist?" or "how many tables are in the room (and not other place)?"
は is a CONTEXT marker, is not a subject thing and it also not an object thing, you could say is a theme thing, but honestly, the word "topic" fits better.
And most certainly が doesn't have anything to know with the unknown, it can mark unknown but it doesn't need to. It marks a "be-er" or a "doer" which sometimes is translated as a "subject" for English learners but this is not a good equivalent. It can also be omitted if the context allows it, for example in Duo sentence, the "be-er" it's already mentioned when you state the topic so there is no need to say テーブルはテーブルが～。
The funny thing is that the video @GabrielYuji96 shared in Spanish explains this perfectly (yes, I also know Spanish, I'm a native in fact), so I guess he didn't really understand what was being told to him.
Also, Duo already accepts both sentences right now.
There's been plenty of comments on this already but I saw that no one commented about my particular issue so I'll stick in my oar and rile the waters too haha.
The thing I got marked wrong for in writing this sentence was for using ですか instead of ありますか. I've found living in Japan that using です in sentences is very common and natural when asking for numbers or when saying numbers. 卵が5個です. 兄弟は何人ですか.
People say things like 兄弟が何人いますか or 部屋にテーブルはいくつありますか less often, and this has been both my personal experience and what I've been told by my Japanese friends and roommates. Frankly, using ある and いる for everything is simply bothersomeーor as the 日本人 say, めんどくさい.
As a final note, the いくつ kanji (幾つ) is very rarely used except for within formal documents or when space is at a premium. Certainly no one writes it by hand.
Japanese sentences are odd in that the only things that truly matter are your particles. The particles mean different things e.g は makes you aware that the thing before it is the topic of the sentence and is known information. に means in. It doesn't matter where you put your nouns, just that the particles match up. If you had テーブルにへやはいくつありますか it would mean "How many rooms are in the table?" because you used the "in" particle for the table and the topic marker particle for your room.
は is the topic marker (meaning "regarding"). に is the location marker (meaning "in"). へやに means "in the room" and テーブルは means "regarding tables". So the sentence translates to something like "Regarding tables, how many are in the room?" (You might also say "speaking of tables..." or "when it comes to tables..." or "on the topic of tables...".)
Yes, either one is fine (whether Duo will accept it or not is a other question. They want to drill the difference between ある and いる I guess). In fact, in ordinary conversation ですか is more common than ありますか or いますか (or their informal versions). If you want to look, I explained it more in another comment on this thread ^.^
で cannot be used here. に and で share a common usage as a marker for location, however, they are not used interchangeably: で is used for location of action, に is used for location of existence. So if the question were "How many tables are dancing in this room?", 「この部屋でいくつテーブルが舞ってしますか？」then you would use で, but in this instance, because the tables aren't doing anything, に has to be used instead.
Note that there is an exception to this rule and that is when the thing that's existing is some kind of event. For instance, if you wanted to say that there is a party in the room, 「この部屋でパーティーがあります。」then you would have to use で instead of に (I guess is that this is due to action that is implied to be happening at the event).
Why do you think the question is about the room?
Think about what the question is: 「いくつありますか？」, "how many are there?". So what is it asking about? Is it the rooms (how many rooms are there?), or is it the tables (how many tables are there?)?
In this question, 「部屋に」, "in the room", is merely a qualifier that is limiting the scope of the question. We don't care how many tables there are in the entire world. We don't care how many tables we might happen to own. All we are interested in is the number of tables at that particular location.
"Regarding the tables, how many are in the room?"
In this case, the Japanese sentence「部屋にテーブルはいくつありますか？」is stressing テーブルは as the topic, you want to know how many tables (and not other things) are in the room.
While in「部屋にはテーブルがいくつありますか？」you are stressing the "inside of the room" part and you want to know "how many tables are in the room (and no other place)".
the topic is only what you are talking about, it can mark anything, it can even be found in the middle of what you would consider a full word because the は particle is a contextual thing, is not the same as が which is a case marker and is part of the logical structure... but yeah both sentences are correct and there is little difference in English besides context.
Also, consider that when you are using a topic you might be omitting logical structure because of convenience. For example, you could say that the full sentence is「テーブルは部屋に『テーブルが』いくつありますか？」but since you are already giving the context with は you don't need to repeat テーブルが which is the grammatical "be-er" of the sentence.
Things closer to the verb are more important, so in that case, you can sometimes move the topic around to move the focus of what you want to say, you can see that happening with the English translation as well.
This sentence, in particular, sounds a bit awkward to me, I would personally phrase it as「部屋にはテーブルがいくつありますか？」but I think you can translate the differences like this:
「部屋『には』テーブル『が』いくつありますか？」"how many tables are in the room? (and no other place)"
「部屋にテーブル『が』いくつありますか？」"how many tables are in the room?". This one is the most neutral one
「部屋にテーブル『は』いくつありますか？」"how many tables (and no other items) are there... in the room?"
「部屋『は』テーブル『が』いくつありますか？」"as for the room, how many tables has it."
「テーブルは部屋にいくつありますか？」"as for tables, how many are in the room?"
Probably not worth trying to translate it though. Just understand that sometimes は implies a contrast when is not expected, and you can also move the focus of things with structure.
At the top of this sentence discussion page you can see the following correct default answer sentence. This is the sentence the word bank tiles are made from:
In Duo's default correct answer sentence, where is this が which you say is necessary to form the answer?
If you want to give your own different correct answer instead of the one Duolingo is teaching, you can type it instead of using the lame word bank feature.
How come is it possible to use wa after both ni and after the subject of the sentence?
This sentence was thrown at me two times, out of part confusion and part curiosity I tried: 1) heya ni teburu wa ikutsu arimasuka 2) heya ni wa teburu ikutsu arimasuka and both were right, so.. how come?
No, those particles don't work
テーブルの部屋 , の links "table" with room" to be "the room of tables" or "table's room"
に and が are particles that can't be combined; に marks the location where something exists, が marks the thing doing the existing
It comes out to something like "How many of the [in the table's room] exist?"
Puni Puni is the most beginner-friendly https://www.punipunijapan.com/category/japanese-grammar/
Tofugu also has a lot of articles on specific grammar structures https://www.tofugu.com/japanese-grammar/sentences-and-clauses/
Tae Kim's grammar guide is a pretty complete and nicely organized resource http://www.guidetojapanese.org/learn/
Pomax is a bit more in depth https://pomax.github.io/nrGrammar/