SQLTeam.com | Weblogs | Forums

Count columns from 2 tables helpp


#1

Hello guys for the first im a german boy my englisch is not so good,

my actuall code is :sunny:
select tVersandartenID, concat(Versandart,"(",count(*),")") as Versandart
from (
select va.tVersandartenID,versandart from tVersandarten va
left join tVersandzonen vz
on va.tVersandartenid = vz.tVersandartenid
group by vz.tVersandartenid,zone
order by Versandart) a
group by tVersandartenID;

my tables are :

table tVersandarten
tVersandartenID | Versandart |
1 | 1
2 | 4
3 | 6

table2. tVersandzonen
tVersandzonenID | Zone | Abkg | Biskg |
1 | 2 | 1 | 2
2 | 2 | 2 | 2

so my actuall code looks like this:

tVersandartenID | Versandart
1 | ~TEXT~ (8)
2 | ~TEXT ~(2)
3 | ~TEXT~(5)
4 | ~text ~ (9)

i need the number of all same zones and how many rows are belong to zones so in the end there need to stand ~TEXT~ (8) 4/60 [ 60 how many belong to zones, 4 how many zones are same ]