Flour is in the grains group but there are a couple of different types of flour. There is whole-wheat flour and refined flour.
Whole-wheat flour contains the entire grain kernel which includes the endosperm, germ, and bran. Whole-wheats are healthier because they contain a lot more fiber.
A grain that has been refined means that the bran and germ have been removed. The reason for this is to make the texture of the flour fine. Usually if the grain has been refined it also means that it has been enriched with iron and certain B vitamins. The problem with these kinds of grains is that fiber is not added back to them. Fiber is a very important part of a balanced diet and this is why many people buy whole-wheat products.
Flour is in the grains food group. That is because flour is made from wheat and wheat is a grain. That makes flour a grain product. Other kinds of flour, such as rice flour or rye flour also fit in this group.
The only other group that you could even imagine flour being in is the fruits and vegetables group. But wheat is not classified as either a fruit or a vegetable.
The other food groups are meat, dairy, and nuts and fats. It is clear that wheat does not belong to any of these groups.
Flour is a carbohydrate, it is mainly made up of carbon and hydrogen hence its name.
Sugars are also in this group, but they are more simple and contain only one or a few subunits so they ar monosaccharides or disaccharides or even oligosaccharides, whereas starches, which is what flour is, contains many subunits, or saccharides that is why it is also called a polysaccharide.
This is a more detailed answer in case you were not referring to the food pyramid, but to macromolecules.