Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SAS Proc SQL-排名前n位(第3位),是一组大学的最高排名,价格如何?(老实说)_Sql_Sas_Proc Sql_Ranking Functions - Fatal编程技术网

SAS Proc SQL-排名前n位(第3位),是一组大学的最高排名,价格如何?(老实说)

SAS Proc SQL-排名前n位(第3位),是一组大学的最高排名,价格如何?(老实说),sql,sas,proc-sql,ranking-functions,Sql,Sas,Proc Sql,Ranking Functions,(这是作业,不会说谎) 我编写了一个ANSI SQL查询 这就产生了 必要的 第三高价格正确 表格样本为 select unique uni, price from ( ( select unique uni, price from ( select unique uni, price from table1 group by uni having price < max(pri

(这是作业,不会说谎)

我编写了一个ANSI SQL查询

这就产生了 必要的 第三高价格正确

表格样本为

select unique uni, price
from
(
(
     select unique uni, price
     from 
     (
          select unique uni, price
          from table1
          group by uni
          having price < max(price)
     )
     group by uni
     having price < max(price)
) 
group by uni
having price < max(price)
)

/很抱歉,我已经很久没有在这里了,我感谢任何帮助,我会提供一个链接到大学,我问导师我是否可以这样做,他说是的,但不是全部代码,大约10%,但是无论如何。///p>在SAS中,您可以使用专有选项
OUTOBS
来限制输出结果集的行数

例如:

使用
OUTOBS=3
创建前三名表格。然后在后续查询中使用该表

data have;
input x @@; datalines;
10 9 8 7 6 5 4 3 2 1 0
;

proc sql;
  reset outobs=3;
  create table top3x as
  select * from have
  order by x descending;

  reset outobs=max;
  * another query;
quit;

您应该(至少)将查询作为问题中的文本而不是图像输入。数据作为文本表也更好。@GordonLinoff谢谢,我会解决的now@GordonLinoff嘿,我可以问你怎么在这里画桌子吗。我在谷歌搜索时得到的结果好坏参半。为SAS帖子提供数据的方法是作为一个独立的数据步骤,使用内嵌数据,这样用户就可以复制并粘贴到SAS会话中,以重现您的示例数据。
data have;
input x @@; datalines;
10 9 8 7 6 5 4 3 2 1 0
;

proc sql;
  reset outobs=3;
  create table top3x as
  select * from have
  order by x descending;

  reset outobs=max;
  * another query;
quit;