一个多表嵌套查询的sql语句
select batch_no "批次号",get_id "分类" from (
select(
select plan1.batch_no from product_plan plan1 where plan1.item_no=(select head1.product_code from wo_head head1 where head1.order_no =bbb)) batch_no,
(select decode(get_id,'BUY','外购件','MAK','自制件','MB','未定') from item where item_no= aaa) get_id
from (select req.item_no aaa,req.order_no bbb from process_req req where req.status_id='C'and req.order_no in(select head.order_no from wo_head head where head.batch_no in (select batch_no from product_plan) or head.product_code in ( select item_no from product_plan )))) order by qty desc
相关文档:
通常,你需要获得当前日期和计算一些其他的日期,例如,你的程序可能需要判断一个月的第一天或者最后一天。你们大部分人大概都知道怎样把日期进行分割(年、月、日等),然后仅仅用分割出来的年、月、日等放在几个函数中计算出自己所需要的日期!
在这篇文章里,我将告诉你如何使用DATEADD和DATEDIFF函数来计算出在你 ......
定义:何为触发器?在SQL Server里面也就是对某一个表的一定的操作,触发某种条件,从而执行的一段程序。触发器是一个特殊的存储过程。
常见的触发器有三种:分别应用于Insert , Update , Delete 事件。
我为什么要使用触发器?比如,这么两个表:
&n ......
为了执行sql语句,我们会在access数据库中执行sql语句,这样方便我们分析。方法如下:
打开access数据库,点击”创建“,在单击“查询设计”,会弹出一个显示表的窗口,关掉。会出现一个sql试图,打开就可以再里面写sql代码了。 ......
废话不多说,上代码
SELECT k
from (
SELECT 'shanghai' AS k from DUAL
UNION ALL
SELECT 'dalian' AS k from DUAL
UNION ALL
SELECT 'beijing' AS k from DUAL
)
ORDER BY CASE
WHEN k = 'beijing'
......