【发布时间】:2013-08-23 14:38:25
【问题描述】:
表结构如下:
Sales: Sales_id, sDate,ccode,qty,amt;
Challan: Ch_id, ch_date,qty,amt;
需要的信息是:
Id | Date | CCode | Type | Qty | Amt
If sales then type = sales; if challan then type = challan ; order by date
我尝试了以下方法:
select s.cust_code,s.cust_name,s.sales_qty,s.sales_amt,c.cust_code,
c.cust_name,c.challan_qty ,c.challan_amt
from sales s inner
join challan c on s.sales_date = c.challan_date
我应该如何放置类型的自定义列并在特定日期显示挑战或销售?
【问题讨论】:
-
如何判断是销售还是挑战?
标签: sql-server join union