IOwnAndPwnU 0 Newbie Poster

This is a logic question (or at least I think it is).

What happens when the select term and group by term do not match? Why?
The sample code is here:

SELECT [B]Name[/B], max(Age)
FROM People
GROUP BY [B]Name[/B]

So what happens if those two bolded field names do not match (i.e. one of them was replaced with another field name)?

Another question which is similar:
Why can't you have B in:

SELECT count(*), A, [B]B[/B]
FROM C
GROUP BY A

So, field B should not be present. Why is that?

Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.