Oracle SQL 排序后取第一条记录 没有记录,怎么回事?
select"T0"."Part_Number""Part_Number","T0"."Vendor_Code""Vendor_Code","T0"."Vendor_Na...
select"T0"."Part_Number" "Part_Number","T0"."Vendor_Code" "Vendor_Code","T0"."Vendor_Name" "Vendor_Name","T0"."Region_Code_" "Region_Code_","T0"."Allocation__" "Allocation__","T0"."Part_Lead_Time_" "Part_Lead_Time_"from(select "TM_PTVN_PART_VENDOR"."CD_PART" "Part_Number", "TM_PTVN_PART_VENDOR"."CD_VENDOR" "Vendor_Code", "TM_PTVN_PART_VENDOR"."DS_VENDOR_NAME" "Vendor_Name", CAST( to_char("TM_PTVN_PART_VENDOR"."CD_REGION") AS CHAR( 2 ) ) "Region_Code_", "TM_PTVN_PART_VENDOR"."PC_ALLOCATION" "Allocation__", case when "TM_PTVN_PART_VENDOR"."NR_PART_LT"<0 then 0 else "TM_PTVN_PART_VENDOR"."NR_PART_LT"end "Part_Lead_Time_"from "DDWH00_EDW_ALL"."TM_PTVN_PART_VENDOR" "TM_PTVN_PART_VENDOR"where "TM_PTVN_PART_VENDOR"."FL_VALIDITY"='Y' and decode("TM_PTVN_PART_VENDOR"."FL_DUMMY", 'Y', "TM_PTVN_PART_VENDOR"."FL_DUMMY", 'N')='N' and "TM_PTVN_PART_VENDOR"."ID_REGN" =3and "TM_PTVN_PART_VENDOR"."CD_REGION" =3and "TM_PTVN_PART_VENDOR"."PC_ALLOCATION">=100 and CAST( to_char("TM_PTVN_PART_VENDOR"."CD_REGION") AS CHAR( 2 ) ) =3order by "Part_Lead_Time_" asc nulls last) "T0"where rownum <2
展开
展开全部
你的rownum用法不对,这样写
select
"T0"."Part_Number" "Part_Number",
"T0"."Vendor_Code" "Vendor_Code",
"T0"."Vendor_Name" "Vendor_Name",
"T0"."Region_Code_" "Region_Code_",
"T0"."Allocation__" "Allocation__",
"T0"."Part_Lead_Time_" "Part_Lead_Time_"
from
(select rownum rn,
"TM_PTVN_PART_VENDOR"."CD_PART" "Part_Number",
"TM_PTVN_PART_VENDOR"."CD_VENDOR" "Vendor_Code",
"TM_PTVN_PART_VENDOR"."DS_VENDOR_NAME" "Vendor_Name",
CAST( to_char("TM_PTVN_PART_VENDOR"."CD_REGION") AS CHAR( 2 ) ) "Region_Code_",
"TM_PTVN_PART_VENDOR"."PC_ALLOCATION" "Allocation__",
case when "TM_PTVN_PART_VENDOR"."NR_PART_LT"<0
then 0
else "TM_PTVN_PART_VENDOR"."NR_PART_LT"
end "Part_Lead_Time_"
from "DDWH00_EDW_ALL"."TM_PTVN_PART_VENDOR" "TM_PTVN_PART_VENDOR"
where "TM_PTVN_PART_VENDOR"."FL_VALIDITY"='Y'
and decode("TM_PTVN_PART_VENDOR"."FL_DUMMY", 'Y', "TM_PTVN_PART_VENDOR"."FL_DUMMY", 'N')='N'
and "TM_PTVN_PART_VENDOR"."ID_REGN" =3
and "TM_PTVN_PART_VENDOR"."CD_REGION" =3
and "TM_PTVN_PART_VENDOR"."PC_ALLOCATION">=100
and CAST( to_char("TM_PTVN_PART_VENDOR"."CD_REGION") AS CHAR( 2 ) ) =3
order by "Part_Lead_Time_" asc nulls last
) "T0"
where rn <2
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询