CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

高难度问题----这个SQL怎么写?

楼主java_xzy(savage)2004-08-03 10:47:05 在 Web 开发 / ASP 提问

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   )  
  问题点数:100、回复次数:5Top

1 楼skyboy0720(曲终人散)回复于 2004-08-03 10:54:02 得分 70

不能比较或排序   text、ntext   和   image   数据类型,除非使用   IS   NULL   或   LIKE   运算符  
  -->  
  已经写得很详细了嘛!Top

2 楼java_xzy(savage)回复于 2004-08-03 11:30:24 得分 0

但是我没有排序text、ntext   和   image   类型的数据   啊Top

3 楼sunjiujiu(绿茶狂人@抵制日货)回复于 2004-08-03 12:32:25 得分 10

你的desc就是排序了啊Top

4 楼xjy521(笑剑影)回复于 2004-08-03 13:44:51 得分 10

哈哈哈Top

5 楼zorou_fatal(The world and system is even)回复于 2004-08-03 14:05:11 得分 10

可以在order   by   或者group   by的时候  
  用cast转一下,转成varchar的Top

相关问题

  • 这样的SQL怎么写?(高难度)
  • 高难度sql 查询语句编写
  • 高难度问题,这个sql语句该怎样写
  • 高难度的SQL语句,能否帮助写出来?
  • 求助一条高难度sql的写法。
  • 一个SQL,高难度
  • 求高难度SQL语句
  • 不好意思:关于“高难度问题,这个sql语句该怎样写”
  • 求救!!请问该SQL语句怎样写啊(高难度动作!!!!)
  • 一个高难度的SQL语句

关键词

  • 排序
  • 数据
  • 服务器
  • 消息
  • view
  • 印
  • px
  • intro
  • 行1不能
  • when charindex

得分解答快速导航

  • 帖主:java_xzy
  • skyboy0720
  • sunjiujiu
  • xjy521
  • zorou_fatal

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo