Hello all,would be glad if anyone could give me a hint / solution for this. Situation (simplyfied)Table t1 material with t1.id, t1.shortcode, t1.descTable t2 items with t2.id, t2.longcode, t2.descTables are linked by t2.longcode of an item (eg. "A44D06") always starts with a t1.shortcode (z.B. "A44") of a material.Resultset should be 3 columns with t1.shortcode, t1.desc and the number of items from t2 that consist of the t1 material:|shortcode...........|desc......................|item_count........||A44.................|tin.......................|14................||A45.................|copper....................|7.................||A46.................|steel.....................|35................|...
In Access 2010 SQL I get a datatype conflict when executing this query:SELECT t1.shortcode, t1.desc, COUNT(t2.id) as item_count FROM t1 INNER JOIN t2 ON t1.shortcode = LEFT(t2.longcode, LEN(t1.shortcode)) GROUP BY t1.shortcode,t1.desc ORDER BY t1.shortcode
Although both t1.shortcode and t2.longcode have the same datatype in the tables (Character/Text), the JOIN condition obviously can't get along with that modified string "LEFT(t2.longcode, LEN(t1.shortcode))". Same error for doing without JOIN and using a simple SELECT from both tables WHERE t1.shortcode = LEFT(t2.longcode, LEN(t1.shortcode)) instead.Does anyone know a solution for the datatype conflict or even a better approach to get the result?THANK YOU!