高难度问题----这个SQL怎么写?
select Product_No,Product_Id,Product_Name,Class_1,Class_2,Product_Intro,Product_Show,P_NewPrice,P_OldPrice,P_Pic,P_Full_Pic,RegTime,Look_Count,p_flag,sum(px1),sum(px2),sum(px3),sum(px4),sum(px5) from view_103730382500180 group by Product_No,Product_Id,Product_Name,Class_1,Class_2,Product_Intro,Product_Show,P_NewPrice,P_OldPrice,P_Pic,P_Full_Pic,RegTime,Look_Count,p_flag order by sum(px5) desc,sum(px1) desc,sum(px3) desc,sum(px4) desc,RegTime desc
本来是ACCESS下运行的。 现在转到SQLSERVER 执行却报告
服务器: 消息 306,级别 16,状态 2,行 1
不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。
服务器: 消息 306,级别 16,状态 1,行 1
不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。
服务器: 消息 306,级别 16,状态 1,行 1
不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。
服务器: 消息 306,级别 16,状态 1,行 1
不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。
服务器: 消息 306,级别 16,状态 1,行 1
不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。
那个视图的写法是:
CREATE VIEW view_103730382500180 AS (select *,(px1 + px2 + px3 + px4) as px5 from (select *,case when charindex('去印',Product_Name)>0 then 90 else 0 end as px1,case when charindex('去印',class_1)>0 or charindex('去印',class_2)>0 then 2 else 0 end as px2,case when charindex('去印',Product_Intro)>0 then 20 else 0 end as px3,case when charindex('去印',product_show)>0 then 10 else 0 end as px4 from Product where (Product_Name like '%去印%' or class_1 like '%去印%' or class_2 like '%去印%' or Product_Intro like '%去印%' or product_show like '%去印%') and shopid=1 and isnull(p_flag,0)<>5) as tableA )UNION all(select *,(px1 + px2 + px3 + px4) as px5 from (select *,case when charindex('去',Product_Name)>0 then 4 else 0 end as px1,case when charindex('去',class_1)>0 or charindex('去',class_2)>0 then 1 else 0 end as px2,case when charindex('去',Product_Intro)>0 then 3 else 0 end as px3,case when charindex('去',product_show)>0 then 2 else 0 end as px4 from Product where (Product_Name like '%去%' or class_1 like '%去%' or class_2 like '%去%' or Product_Intro like '%去%' or product_show like '%去%') and shopid=1 and isnull(p_flag,0)<>5) as tableB )UNION all(select *,(px1 + px2 + px3 + px4) as px5 from (select *,case when charindex('印',Product_Name)>0 then 4 else 0 end as px1,case when charindex('印',class_1)>0 or charindex('印',class_2)>0 then 1 else 0 end as px2,case when charindex('印',Product_Intro)>0 then 3 else 0 end as px3,case when charindex('印',product_show)>0 then 2 else 0 end as px4 from Product where (Product_Name like '%印%' or class_1 like '%印%' or class_2 like '%印%' or Product_Intro like '%印%' or product_show like '%印%') and shopid=1 and isnull(p_flag,0)<>5) as tableB )