本文介绍了SQL创建多个查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定如何最好地提出这个问题或者是否可能。我无法访问"创建" sql中的表,但是我需要创建一个代码来创建select多个语句,结果可以在整个sql代码的
内重复使用多次。我不认为嵌套会起作用,因为我需要独立引用每个查询。


示例


创建查询1


创建查询2


创建查询3


创建查询4


然后查询2需要引用查询1的结果,


查询3需要引用查询2的结果


查询4需要引用查询1和3的结果


不确定这是否有意义,就像我说我很难在脑海中思考如何运作。 背景是我有一个sas代码(生成appox 20表),我需要将该代码写入sql语句
以备将来使用。


感谢您的帮助!

解决方案

Im not sure how to best ask this question or if its even possible. I don't have access to 'Create" tables in sql, however I need to create a code that creates select multiple statements where the results can be reused multiple times within the entire sql code. I don't think nested will work because I need to independently reference each query.

example

create query 1

create query 2

create query 3

create query 4

then query 2 need to reference the results from query 1,

query 3 needs to reference results from query 2

query 4 needs to reference results from query 1 and 3

Not sure if that makes sense, like I said Im having a hard time thinking this through in my head of how it would work.  The background is that I have a sas code (which generates appox 20 tables) and I need to get that code written into a sql statement for future use.

Thanks for any help!

解决方案


这篇关于SQL创建多个查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 22:24