问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

求教一条比较复杂的sql查询语句

发布网友 发布时间:2022-04-08 20:15

我来回答

2个回答

懂视网 时间:2022-04-09 00:36

= REPLACE(content,‘国家级‘,‘‘),content = REPLACE(content,‘世界级‘,‘‘),content = REPLACE(content,‘最高级‘,‘‘) ,content = REPLACE(content,‘最佳‘,‘‘),content = REPLACE(content,‘首个‘,‘‘),content = REPLACE(content,‘首选‘,‘‘) ,content = REPLACE(content,‘唯一‘,‘‘),content = REPLACE(content,‘世界级‘,‘‘),content = REPLACE(content,‘世界级‘,‘‘) ,content = REPLACE(content,‘最好‘,‘‘),content = REPLACE(content,‘最大‘,‘‘),content = REPLACE(content,‘精确‘,‘‘) ,content = REPLACE(content,‘顶级‘,‘‘),content = REPLACE(content,‘最高‘,‘‘),content = REPLACE(content,‘最低‘,‘‘) ,content = REPLACE(content,‘最‘,‘‘),content = REPLACE(content,‘最具‘,‘‘),content = REPLACE(content,‘最便宜‘,‘‘) ,content = REPLACE(content,‘最新‘,‘‘),content = REPLACE(content,‘最先进‘,‘‘),content = REPLACE(content,‘最大程度‘,‘‘) ,content = REPLACE(content,‘最新技术‘,‘‘),content = REPLACE(content,‘最先进科学‘,‘‘),content = REPLACE(content,‘国家级产品‘,‘‘) ,content = REPLACE(content,‘填补国内空白‘,‘‘),content = REPLACE(content,‘绝对‘,‘‘),content = REPLACE(content,‘独家‘,‘‘) ,content = REPLACE(content,‘首家‘,‘‘),content = REPLACE(content,‘最先进‘,‘‘),content = REPLACE(content,‘万能‘,‘‘) ,content = REPLACE(content,‘第一品牌‘,‘‘),content = REPLACE(content,‘金牌‘,‘‘),content = REPLACE(content,‘名牌‘,‘‘) ,content = REPLACE(content,‘优秀‘,‘‘),content = REPLACE(content,‘最先‘,‘‘),content = REPLACE(content,‘顶级‘,‘‘) ,content = REPLACE(content,‘独家‘,‘‘),content = REPLACE(content,‘全网销量第一‘,‘‘),content = REPLACE(content,‘全球首发‘,‘‘) ,content = REPLACE(content,‘全国首家‘,‘‘),content = REPLACE(content,‘全网首发‘,‘‘),content = REPLACE(content,‘世界领先‘,‘‘) ,content = REPLACE(content,‘顶级工艺‘,‘‘),content = REPLACE(content,‘最新科学‘,‘‘),content = REPLACE(content,‘最新技术‘,‘‘) ,content = REPLACE(content,‘最先进加工工艺‘,‘‘),content = REPLACE(content,‘最时尚‘,‘‘),content = REPLACE(content,‘极品‘,‘‘) ,content = REPLACE(content,‘顶级‘,‘‘),content = REPLACE(content,‘顶尖‘,‘‘),content = REPLACE(content,‘终极‘,‘‘) ,content = REPLACE(content,‘王牌‘,‘‘),content = REPLACE(content,‘销量冠军‘,‘‘),content = REPLACE(content,‘最受欢迎‘,‘‘) ,content = REPLACE(content,‘NO.1‘,‘‘),content = REPLACE(content,‘Top1‘,‘‘),content = REPLACE(content,‘极致‘,‘‘) ,content = REPLACE(content,‘永久‘,‘‘),content = REPLACE(content,‘王牌‘,‘‘),content = REPLACE(content,‘掌门人‘,‘‘) ,content = REPLACE(content,‘领袖品牌‘,‘‘),content = REPLACE(content,‘独一无二‘,‘‘),content = REPLACE(content,‘独家‘,‘‘) ,content = REPLACE(content,‘绝无仅有‘,‘‘),content = REPLACE(content,‘前无古人‘,‘‘),content = REPLACE(content,‘史无前例‘,‘‘) ,content = REPLACE(content,‘第一‘,‘‘) WHERE id = 2;
UPDATE shopnc_goods_common SET goods_body = 

INSERT(goods_body, INSTR(goods_body,‘<div class="p_titles_2">商品特色</div>‘), INSTR(goods_body,‘<div class="p_titles_2">商品参数</div>‘)- INSTR(goods_body,‘<div class="p_titles_2">商品特色</div>‘),‘‘)

WHERE gc_id_2 in (294,284,289,261,216) and goods_body LIKE ‘%商品特色%‘
SELECT shopnc_cps.order_sn as 订单号,shopnc_orders.buyer_name as 用户名,FROM_UNIXTIME(shopnc_orders.add_time,‘%Y-%m-%d %H:%i:%S‘) as 下单时间,
shopnc_order_goods.goods_name as 商品名称,shopnc_orders.store_name as 店铺名,shopnc_orders.CustomerNo as 用户编号,
CASE
WHEN shopnc_orders.order_state = ‘0‘ THEN ‘以取消‘
WHEN shopnc_orders.order_state = ‘10‘ THEN ‘未付款‘
WHEN shopnc_orders.order_state = ‘20‘ THEN ‘以付款‘
WHEN shopnc_orders.order_state = ‘30‘ THEN ‘以发货‘
WHEN shopnc_orders.order_state = ‘40‘ THEN ‘以收货‘
END AS 订单状态,

CASE
WHEN shopnc_goods.gc_id_1 = ‘1‘ THEN ‘汽车精品‘
WHEN shopnc_goods.gc_id_1 = ‘15‘ THEN ‘服装鞋帽‘
WHEN shopnc_goods.gc_id_1 = ‘53‘ THEN ‘箱包配饰‘
WHEN shopnc_goods.gc_id_1 = ‘77‘ THEN ‘数码家电‘
WHEN shopnc_goods.gc_id_1 = ‘124‘ THEN ‘个护彩妆‘
WHEN shopnc_goods.gc_id_1 = ‘159‘ THEN ‘家居日用‘
WHEN shopnc_goods.gc_id_1 = ‘215‘ THEN ‘珠宝收藏‘
WHEN shopnc_goods.gc_id_1 = ‘264‘ THEN ‘食品保健‘
WHEN shopnc_goods.gc_id_1 = ‘302‘ THEN ‘旅游度假‘
WHEN shopnc_goods.gc_id_1 = ‘313‘ THEN ‘母婴玩具‘
WHEN shopnc_goods.gc_id_1 = ‘319‘ THEN ‘燕京八绝‘
WHEN shopnc_goods.gc_id_1 = ‘354‘ THEN ‘手机充值‘
WHEN shopnc_goods.gc_id_1 = ‘355‘ THEN ‘其他分类‘
END as 商品分类,

CASE
WHEN shopnc_orders.payment_code = ‘offline‘ THEN ‘货到付款‘
WHEN shopnc_orders.payment_code = ‘online‘ THEN ‘在线支付‘
WHEN shopnc_orders.payment_code = ‘wxpay‘ THEN ‘微信支付‘
WHEN shopnc_orders.payment_code = ‘alipay‘ THEN ‘支付宝‘
WHEN shopnc_orders.payment_code = ‘unionpay‘ THEN ‘银联‘
WHEN shopnc_orders.payment_code = ‘pingan‘ THEN ‘平安银行‘
ELSE ‘不知道什么支付方式‘
END
as 支付方式,shopnc_order_goods.goods_id as 商品ID,shopnc_order_goods.goods_price as 商品价格,shopnc_order_goods.goods_pay_price as 订单支付价格,
shopnc_order_goods.goods_num as 商品数量,shopnc_order_goods.unit_code as 德珍商品编号,shopnc_order_goods.goods_usevipdiscount as 会员折扣,shopnc_order_goods.goods_usediscount as 代金券,
shopnc_order_goods.goods_useuserpoint as 使用购物金,shopnc_order_goods.goods_freight as 运费,shopnc_order_goods.living_goods_discount as 正在直播商品优惠,shopnc_order_goods.yihe_cuxiao as 移动端货到付款优惠,
shopnc_order_goods.gc_id as 商品分类 ,
CASE
WHEN shopnc_goods.gc_id_1 IN (15,53,124,159,264) AND shopnc_goods.goods_promotion_type =0 THEN ‘5%‘
WHEN shopnc_goods.gc_id_1 IN (15,53,124,159,264) AND shopnc_goods.goods_promotion_type != 0 THEN ‘3%‘
WHEN shopnc_goods.gc_id_1 IN (215,302) THEN ‘3%‘
WHEN shopnc_goods.gc_id_1 = ‘77‘ AND shopnc_goods.gc_id_2 != ‘110‘ THEN ‘3%‘
ELSE ‘0%‘
END as 佣金比例 ,

(CASE
WHEN shopnc_goods.gc_id_1 IN (15,53,124,159,264) AND shopnc_goods.goods_promotion_type =0 THEN 0.05
WHEN shopnc_goods.gc_id_1 IN (15,53,124,159,264) AND shopnc_goods.goods_promotion_type != 0 THEN 0.03
WHEN shopnc_goods.gc_id_1 IN (215,302) THEN 0.03
WHEN shopnc_goods.gc_id_1 = ‘77‘ AND shopnc_goods.gc_id_2 != ‘110‘ THEN 0.03
ELSE 0
END)*(shopnc_order_goods.goods_pay_price - 21) AS 佣金金额,‘16‘ AS 包装费 ,‘5‘ AS 邮费 ,
 shopnc_order_goods.rcb as 使用充值卡金额,shopnc_order_goods.pd as 使用预付款金额,

CASE
WHEN shopnc_cps.c_id = ‘17574‘ THEN ‘汽车精品‘
WHEN shopnc_cps.c_id = ‘18000‘ THEN ‘领克特‘
WHEN shopnc_cps.c_id = ‘19000‘ THEN ‘唯一传媒‘
END as cps来源,
 
CASE
WHEN shopnc_orders.client = ‘1‘ THEN ‘网站‘
WHEN shopnc_orders.client = ‘2‘ THEN ‘wap‘
WHEN shopnc_orders.client = ‘3‘ THEN ‘微信‘
END as 订单来源 ,
shopnc_order_push.order_push_sn as 德珍订单号

FROM shopnc_cps LEFT JOIN shopnc_orders ON shopnc_cps.order_sn = shopnc_orders.order_sn LEFT JOIN shopnc_order_goods ON shopnc_orders.order_id = shopnc_order_goods.order_id LEFT JOIN
 shopnc_goods ON shopnc_order_goods.goods_id =shopnc_goods.goods_id LEFT JOIN shopnc_order_push ON shopnc_orders.order_sn = shopnc_order_push.order_sn
 WHERE shopnc_orders.add_time >= ‘1435680000‘ and shopnc_orders.add_time <= ‘1438358400‘ 

最后一个有点复杂

一些稍微复杂点的sql语句

标签:

热心网友 时间:2022-04-08 21:44

SELECT COUNT(T.姓名) FROM TABLE表 T
GROUP BY T.姓名,T.商品名称 HAVING COUNT(T.商品名称) = n

--
产品数量为n
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
体育理念体育理念 有关体育的格言和理念 什么是体育理念 万里挑一算彩礼还是见面礼 绿萝扦插多少天后发芽 绿萝扦插多久发芽 扦插绿萝多久发芽 炖牛排骨的做法和配料 网络诈骗定罪标准揭秘 “流水不争先”是什么意思? 网易员工收入工资表 网易一般员工收入多少 问一下那些在腾讯新闻,网易新闻里发评论性文章,或者新闻的那些人算不算记者还是网络编辑,工资水平怎么 网易自媒体平台审核过了有收益吗? 荣耀play64g的可以去扩容吗 你好,我的荣耀play可以支持内存扩展吗? 有在网易这边拿到稿费或者版权费吗 网易博客怎么赚钱快? 网易文章点赞超过一万有多少钱- 问一问 荣耀play4支不支持插内存卡? 既是形声字又是形近字的有些什么字 既加旦念什么 夏天开哪些花? “既”在造字结构中属于形声字吗? 鼓、即、帝 分别是会意字还是形声字? 即是形声字吗 6379代表什么爱情意思? 融四岁能让梨香九龄能温度中融指的是 哪个银行信用卡额度高些 融四岁能让梨中融指的是什么? 苹果照片怎么打马赛克 我30年房贷利率为什么一直不变 我30年工龄,年假是多少天,我从没有休过,怎么办。 我和老公30年了,这几年他对我不理不睬、我感觉精神都要出问题了我怎么办? 按照新出台的退休规定,我30年的工龄,退休时,一个月能拿到多少钱 我一个人生活了三十年 初恋悄悄找了我30年,我该怎么办? 我30年工龄交了170.287.28元退休能拿多少工资? 我30岁,30年了,已经和家人有无法弥补的矛盾,该怎么办?原因是家人管的太严,什么都*我,侮辱我 我30年前买的土房子现在垮台了,能退回给卖主吗? 我30年前就居住在中国英语怎么说 从顾客购买决策过程分析,企业在市场上主要有哪些竞争者? 我自卑了30年怎么办 我妈养我30年,要30万彩礼过分吗? 我的工龄30年,下个月退休,不知拿多少退休金 青蒜炒豆腐片的做法,青蒜炒豆腐片怎么做好吃 30年弹指一挥间不知不觉我已到了什么之年? 豆腐和蔬菜搭配可以做哪些菜? 企业在目标市场的竞争地位有几种类型 大家好,我三十年前我让别人强奸了,现在还能报警吗?