Specific cross-SQL statements:
Select A.part_no,a.part_name,
--sum (B.cost)
SUM (case when b.cost_id = ' m ' then b.cost else 0 end) as cost_100,
SUM (case when b.cost_id = ' Then ' b.cost else 0) as cost_200,
SUM (case when b.cost_id = ' Then ' b.cost else 0) as cost_300,
SUM (case when b.cost_id = ' 321 ' then b.cost else 0-end) as cost_321
From Test_part_cost_tab A,test_part_cost_dt_tab b
where a.part_no = B.part_no
GROUP BY A.part_no,a.part_name
PS: If the main table has data, from the table does not have the data, after the cross will not have the corresponding information
The solution is to use an outer join in the Where condition
where a.part_no = B.part_no (+)
Resources:
Http://www.cnblogs.com/iouniuniu/archive/2004/04/05/5238.aspx ==> The syntax of this article is different from the syntax in this paper
Http://it.icxo.com/htmlnews/2004/11/11/454293.htm
Http://www.itpub.net/176727.html
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service