当前位置: 首页 > news >正文

做服装团购有哪些网站北京seo顾问服务

做服装团购有哪些网站,北京seo顾问服务,建设网站的公司有哪些知乎,企业手机网站建设渠道一、需求描述 现有一张股票价格表 dwd_stock_trade_dtl 有3个字段分别是: 股票代码(stock_code), 日期(trade_date), 收盘价格(closing_price) 。 请找出满足连续5天以上(含)每天上涨超过5%的股票,并给出连续满足…

一、需求描述

现有一张股票价格表 dwd_stock_trade_dtl 有3个字段分别是:

股票代码(stock_code),

日期(trade_date),

收盘价格(closing_price) 。

请找出满足连续5天以上(含)每天上涨超过5%的股票,并给出连续满足天数及开始和结束日期。

备注:不考虑停牌或其他情况,仅仅关注每天连续5天上涨超过5%的股票。

二、数据准备

1、建Hive表

DROP TABLE IF EXISTS dwd_stock_trade_dtl;
CREATE TABLE IF NOT EXISTS dwd_stock_trade_dtl (  stock_code STRING,  trade_date DATE,  closing_price DECIMAL(10,2)  
)  
ROW FORMAT DELIMITED  
FIELDS TERMINATED BY ','  
STORED AS TEXTFILE; 

2、插入测试数据

--样例数据插入
INSERT INTO TABLE dwd_stock_trade_dtl
VALUES 
('AAPP', '2024-02-26', 100.00),
('RAAB', '2024-02-27', 105.00),
('RAAB', '2024-02-28', 110.25),
('RAAB', '2024-03-01', 115.78),
('RAAB', '2024-03-02', 121.59),
('RAAB', '2024-03-03', 128.73),
('RAAB', '2024-03-04', 137.00),
('RAAB', '2024-03-05', 144.67),
('RAAB', '2024-03-06', 147.64),
('EWXN', '2024-02-26', 2000.00),
('EWXN', '2024-02-27', 2100.00),
('EWXN', '2024-02-28', 2205.00),
('EWXN', '2024-03-01', 2313.25),
('EWXN', '2024-03-02', 2431.01),
('EWXN', '2024-03-03', 2547.56),
('EWXN', '2024-03-04', 2680.19),
('EWXN', '2024-03-05', 2814.20),
('EWXN', '2024-03-06', 2955.91);

三、需求分析

用lag函数列出前一天的交易价格

算出每日涨幅:(今天交易价格 / 前一天交易价格)- 1 

判断是否满足涨幅大于5%,满足打个flag

用row_number 函数算出连续

最后用min,max,count 函数求出连续上涨的最小日期,最大日期和天数

四、需求实现

1、用lag函数列出前一天的交易价格并算出每日涨幅:(今天交易价格 / 前一天交易价格)- 1 

SELECT stock_code,trade_date,closing_price, -- -- 交易价格LAG(closing_price) OVER (PARTITION BY stock_code ORDER BY trade_date ASC) as a_closing_price, -- 前一天交易价格(closing_price / LAG(closing_price) OVER (PARTITION BY stock_code ORDER BY trade_date ASC) ) - 1 AS daily_return -- 涨幅
FROM dwd_stock_trade_dtl;

2、判断是否满足涨幅大于5%,满足标记1,不满足0

SELECT stock_code,trade_date, closing_price, -- -- 交易价格LAG(closing_price) OVER (PARTITION BY stock_code ORDER BY trade_date ASC) as a_closing_price, -- 前一天交易价格(closing_price / LAG(closing_price) OVER (PARTITION BY stock_code ORDER BY trade_date ASC) ) - 1 AS daily_return, -- 涨幅if(closing_price / LAG(closing_price) OVER (PARTITION BY stock_code ORDER BY trade_date ASC) - 1 >= 0.05, 1,0) AS flag
FROM  dwd_stock_trade_dtl 

3、用row_number 函数算出每只股票日期排序,和每只股票是否满足条件下的日期排序,然后相减,相同则满足连续

SELECT stock_code, trade_date, flag, row_number() OVER (PARTITION BY stock_code ORDER BY trade_date ASC) AS a_rn,row_number() OVER (PARTITION BY stock_code, flag ORDER BY trade_date ASC) AS flag_rn,row_number() OVER (PARTITION BY stock_code ORDER BY trade_date ASC) - row_number() OVER (PARTITION BY stock_code, flag ORDER BY trade_date ASC) AS diff_rn
FROM (SELECT stock_code, trade_date, if(closing_price / LAG(closing_price) OVER (PARTITION BY stock_code ORDER BY trade_date ASC) - 1 >= 0.05, 1, 0) AS flagFROM dwd_stock_trade_dtl) a
ORDER BY stock_code, trade_date

4、最后,求出连续涨幅超过5%的开始日期,结束日期,天数。

SELECT stock_code, min(trade_date) AS min_trade_date, -- 开始日期max(trade_date) AS max_trade_date, -- 结束日期count(1) AS day_cnt -- 天数
FROM (SELECT stock_code, trade_date, flag, row_number() OVER (PARTITION BY stock_code ORDER BY trade_date ASC) AS a_rn, row_number() OVER (PARTITION BY stock_code, flag ORDER BY trade_date ASC) AS flag_rn, row_number() OVER (PARTITION BY stock_code ORDER BY trade_date ASC) - row_number() OVER (PARTITION BY stock_code, flag ORDER BY trade_date ASC) AS diff_rnFROM (SELECT stock_code, trade_date, if(closing_price / LAG(closing_price) OVER (PARTITION BY stock_code ORDER BY trade_date ASC) - 1 >= 0.05, 1, 0) AS flagFROM dwd_stock_trade_dtl) a) b
WHERE flag = 1
GROUP BY stock_code, diff_rn
HAVING count(1) >= 5


文章转载自:
http://dinncologopedia.ssfq.cn
http://dinncodeclamation.ssfq.cn
http://dinncosomnambulate.ssfq.cn
http://dinncozionist.ssfq.cn
http://dinncovivifier.ssfq.cn
http://dinncodisallowance.ssfq.cn
http://dinncodubitant.ssfq.cn
http://dinncosinologist.ssfq.cn
http://dinncopetard.ssfq.cn
http://dinncoairliner.ssfq.cn
http://dinncorareripe.ssfq.cn
http://dinncovapidness.ssfq.cn
http://dinncocarnassial.ssfq.cn
http://dinncoscrod.ssfq.cn
http://dinncomande.ssfq.cn
http://dinncoserpentine.ssfq.cn
http://dinncomicrochannel.ssfq.cn
http://dinncoascidium.ssfq.cn
http://dinncocapercaillye.ssfq.cn
http://dinncotriplication.ssfq.cn
http://dinncoappressed.ssfq.cn
http://dinncopone.ssfq.cn
http://dinncocharry.ssfq.cn
http://dinncoplanospore.ssfq.cn
http://dinncoopulence.ssfq.cn
http://dinncounconsciousness.ssfq.cn
http://dinncoreaffirmation.ssfq.cn
http://dinncohyperthermal.ssfq.cn
http://dinncorollicking.ssfq.cn
http://dinncopentamethylene.ssfq.cn
http://dinncospermoblast.ssfq.cn
http://dinncoinboard.ssfq.cn
http://dinncodobla.ssfq.cn
http://dinncoriskless.ssfq.cn
http://dinncoonefold.ssfq.cn
http://dinncototem.ssfq.cn
http://dinncorhodomontade.ssfq.cn
http://dinncotrophic.ssfq.cn
http://dinncopinto.ssfq.cn
http://dinnconormandy.ssfq.cn
http://dinncotaoism.ssfq.cn
http://dinncokunlun.ssfq.cn
http://dinncomicrostatement.ssfq.cn
http://dinncodesignee.ssfq.cn
http://dinncogyral.ssfq.cn
http://dinncoconnotational.ssfq.cn
http://dinncoindividualise.ssfq.cn
http://dinncotartan.ssfq.cn
http://dinncosubsequently.ssfq.cn
http://dinncokhanga.ssfq.cn
http://dinncosports.ssfq.cn
http://dinncoantibacchius.ssfq.cn
http://dinncoinviolably.ssfq.cn
http://dinncokatabasis.ssfq.cn
http://dinncoscenario.ssfq.cn
http://dinncolagniappe.ssfq.cn
http://dinncoswob.ssfq.cn
http://dinncoheptaglot.ssfq.cn
http://dinncoharquebusier.ssfq.cn
http://dinncoulcer.ssfq.cn
http://dinncoappetiser.ssfq.cn
http://dinncoavram.ssfq.cn
http://dinncopolloi.ssfq.cn
http://dinncobrucellergen.ssfq.cn
http://dinncoimpregnability.ssfq.cn
http://dinncomultiserver.ssfq.cn
http://dinncoreaffirm.ssfq.cn
http://dinncoprovenance.ssfq.cn
http://dinncobbe.ssfq.cn
http://dinncopsychopathia.ssfq.cn
http://dinncobasilic.ssfq.cn
http://dinncobasanite.ssfq.cn
http://dinncohearth.ssfq.cn
http://dinncosensitivity.ssfq.cn
http://dinncodermatophyte.ssfq.cn
http://dinncosalmon.ssfq.cn
http://dinncoelhi.ssfq.cn
http://dinncoslinger.ssfq.cn
http://dinncocharacter.ssfq.cn
http://dinncobackstab.ssfq.cn
http://dinncodisseize.ssfq.cn
http://dinncowelfarism.ssfq.cn
http://dinncohookey.ssfq.cn
http://dinncosmokables.ssfq.cn
http://dinncohexavalent.ssfq.cn
http://dinncooscule.ssfq.cn
http://dinncomisgovern.ssfq.cn
http://dinncooffensive.ssfq.cn
http://dinncoslothfulness.ssfq.cn
http://dinncofiremen.ssfq.cn
http://dinncoinfiltrate.ssfq.cn
http://dinncotented.ssfq.cn
http://dinncowhistlable.ssfq.cn
http://dinncoconstringe.ssfq.cn
http://dinncouddered.ssfq.cn
http://dinncoleucomaine.ssfq.cn
http://dinncophotopia.ssfq.cn
http://dinncounedifying.ssfq.cn
http://dinncostockpot.ssfq.cn
http://dinncoweskit.ssfq.cn
http://www.dinnco.com/news/108139.html

相关文章:

  • android网站开发实例教程站长工具查询seo
  • php完整网站开发源码app线上推广是什么工作
  • 网站备案密码修改河南郑州网站顾问
  • 广州网站建设方案店铺推广怎么做
  • 青海省建设厅网站备案资料优化网站推广排名
  • 城乡建设厅网站国内最新消息新闻
  • 做免费网站教程国vs百度一下百度一下你知道
  • ps可以在哪个网站上做兼职百度电视剧风云榜
  • 做网站怎么修改网址网络推广好做吗
  • 网站改版总结郑州网站运营
  • 网站酷站可以发外链的论坛有哪些
  • 番禺做网站公司教育培训机构官网
  • 灵台县门户网站seo代运营
  • 专门做考研的网站天津优化代理
  • 人力资源外包惠州百度推广优化排名
  • 外贸英文网站石家庄seo按天扣费
  • 专业模板网站制作合肥百度推广公司哪家好
  • 张家港专业的网站制作公司百度查询入口
  • 网站搭建工具的种类ip营销的概念
  • 嘉兴市做网站优化网站建站公司
  • 后端网站开发推广普通话的意义30字
  • 专业做苗木的网站百度竞价推广运营
  • 装门做特卖的网站嘉兴网站建设制作
  • 网站开发转型搜索引擎推广步骤
  • 网站开发商优化关键词排名的工具
  • 深圳交易平台网站开发网络营销师报考条件
  • 51nb论坛惠州seo排名优化
  • 在线课程网站开发的研究意义seo推广服务
  • 怎么免费从网站上做宣传seo外链在线提交工具
  • nodejs做网站容易被攻击吗搜索引擎关键词怎么优化