JOIN CROSS table
Table for bom this is the source table
Pictures of the second to the fourth line is the result of crosstab I want: his watch on the basis of the results of production area horizontal display reports Rows into columns : iphone 5 based products processing center back to classify horizontally Please help thank you very much
mfkpie8： 你好， 谢谢你提出的有关SQLAnywhere的问题.可是你的有些问题我们不完全理解.所以你是否能用中文提出你所有问题?我们尽量帮助你. 谢谢!
answered 21 Nov '13, 12:34
So what you want to do is to pivot the table into a different format. SQL Anywhere does not currently let you directly do this but you can do it manually by the strategic use of aggregate operations. For example:
select product_name, '' as demand_for_product, list( if production_center = 'china-taiwan' then part_name else '' endif, '' ) as part_name_1, sum( if production_center = 'china-taiwan' then quantity else 0 endif ) as quantity_1, list( if production_center = 'china-shenzhen' then part_name else '' endif, '' ) as part_name_2, sum( if production_center = 'china-shenzhen' then quantity else 0 endif ) as quantity_2, list( if production_center = 'usa' then part_name else '' endif, '' ) as part_name_3, sum( if production_center = 'usa' then quantity else 0 endif ) as quantity_3 from BOM group by product_name;
answered 22 Nov '13, 14:44
Below the BOM (picture) is the source table, I want him to make cross-tabular equation as excel first two rows. How should I write code form You can understand the crosstab, I put on a production area inside the header row.
Dynamic SQL code ? 1 2 3 4 5 6
现有表 BOM table product_name(主产品) WO_bom(材料名称) machining center(加工中心) IPhone 5 shell(手机外壳) china-taiwan(中国台湾) iphone 5 mainbord(手机主板) china-shenzhen(中国深圳) IPhone 5 blunt appliances(冲电器) USA 想要的表结构为： result for:
Rows into columns
answered 21 Nov '13, 21:12