Topic: Sampling of several tables with record count count in one of them

All good afternoon!
Help to understand connection of the given several tables please.
At once I will tell, I not the student doing to a lab, simply faced on operation a problem which it is impossible to solve.
A problem Essence:
There are two tables (actually more but if help to understand I extrapolate on necessary kol-in itself):

``````account
number group
40702 1
40802 1
33021 3
33023 3
33024 3
33025 3
groups
id name
1 regular accounts
2 obsolete accounts
3 vip accounts``````

I try to count an amount of accounts in each group and to deduce in a type:

``````account.group count (account.group) groups.name
1 2 regular accounts
3 4 vip accounts``````

Here such request does not work since groups.name is not grouped

``````select account.group count (account.group), groups.name
from account, groups
where account.group = groups.name
group by account.group order by account.group``````

Re: Sampling of several tables with record count count in one of them

group by account.group, groups.name

Re: Sampling of several tables with record count count in one of them

295 wrote:

Here such request does not work since groups.name is not grouped

Well so .

Re: Sampling of several tables with record count count in one of them

295;
Try to group at first, and then to connect a group title

Re: Sampling of several tables with record count count in one of them

295 wrote:

``````where account.group = groups.&gt;&gt;&gt; id &lt;&lt;&lt;
group by account.group&gt;&gt;&gt;, groups.name &lt;&lt;&lt;``````

?

Re: Sampling of several tables with record count count in one of them

group by account.group, groups.name

Yes, here so it turned out, thanks.
And who answered all too thanks, now I will understand!

Re: Sampling of several tables with record count count in one of them

295;
I  two
1)

``````select account.group, cc, groups.name
from (select account.group, count (account.group)  from account group by account.group) account, groups
where account.group = groups.id
order by account.group``````

And
2)

``````select account.group count (account.group), MIN (groups.name) name
from account, groups
where account.group = groups.id
group by account.group order by account.group``````

1 ray, but because of laziness  and the second
.....
stax

Re: Sampling of several tables with record count count in one of them

Stax;
Thanks, I here so made as a result:

``````select account.group count (account.group), groups.name
from account, groups
where account.group = groups.id
group by account.group, groups.name order by account.group``````

In the first message there the pair of errors was, which here already marked.
All once again thanks, are very pleasant that at this forum sympathetic people

Re: Sampling of several tables with record count count in one of them

295;
Personally I for myself eliminated such variant;
Considered what to sort on name
Though many so arrive
.....
stax