Buy Now
Sign in

Count of records with 2 tables in 1 read_data

Fredolino , January 23 2020, 11:42
Fredolino 636
January 23 2020, 11:42 #390874
 Answer
Hi,
I have one read_data (name: read_count_arten_lkr) with to tables:

tb_1 = id, landkreis, ...
(1, landkreisA)
(2, landkreisB)
(3, landkreisC)

Model = Arten_lkr
Select type: All matching records
Field to retrieve:
Arten_lkr.id
Arten_lkr.landkreis
Arten.art_id

Group fields:
Arten_lkr.landkreis
---------
tb_2 = beo_art_id, art_id, ...
(1, 1,)
(2, 1,)
(3, 1,)
(4, 1,)
(5, 2,)
(6, 2,)
(7, 3,)

Model = Arten
Related to: Arten_lkr
Relation: One matching record, foreign key at the related table
Fields to retrieve: count(Arten.art_id):Arten.count_of_art
----------
Loop (name: loop17)
Data provider: {var:read_count_arten_lkr}
Loop body: {var:loop17.row.Arten.count_of_art}
-------
Table (name: lkr_table)
Data provider: {var:read_count_arten_lkr}

Column list:
Arten_lkr.landkreis:landkreis
Arten.art_id:ANZ

Column view: Arten.art_id:{var.count:read_count_arten_lkr}
---------
The problem is the result.
The column with "landkreis" is correct.
Only the number in the "ANZ" column with "Arten.art_id" shows incorrect results.

I read this as help. But it doesn't work for me
http://www.chronoengine.com/forums/posts/t107292/count-on-another-table?keywords=count%20records
F.