从有序查询中选择顶部到新表中

时间:2015-04-30 21:09:13

标签: sql sql-server

我正在尝试使用查询结果创建一个新表,但我在查询结束时收到语法错误。这是查询:

$('body[data-id="myid"]').html()

2 个答案:

答案 0 :(得分:1)

FROM子句中的子查询必须具有别名

select top 1455 *
into new_table
from tbl_patients_problems_to_snomed_buckets_2014
where SnoMedScui not in (select SnoMedScui from groups_first_round)
order by GroupName

答案 1 :(得分:0)

from子句中的子查询需要别名:

select *
into new_table
from
    (select top(1455) * 
    from tbl_patients_problems_to_snomed_buckets_2014
    where SnoMedScui not in 
        (select SnoMedScui from groups_first_round)
    order by GroupName
    ) MyTableAlias