M*****8 发帖数: 17722 | 1 【 以下文字转载自 Stock 讨论区 】
发信人: MB80528 (肥猫(Contrarian)[食MM而肥]), 信区: Stock
标 题: Re: CTE halted today
发信站: BBS 未名空间站 (Wed Aug 17 20:36:03 2011, 美东)
......................
中概基本就是墙街的ATM。
中国公司得个虚幻的面子,
墙街轻松插管吸血得银子。
双方各取所需,皆大欢喜。
中概价格波动实况如下。
SYMBOL DATE PRICE FORECAST1 PERCENT1 FORECAST2 PERCENT2
CTE, 20110816, 2.3500, 0.3612, 15.4, -0.0053, -0.2,
CTE, 20110815, 3.9900, -1.8662, -46.8, -1.7919, -44.9,
CTE, 20110812, 3.8500, -0.1256, -3.3, -0.1914,... 阅读全帖 |
|
M*****8 发帖数: 17722 | 2 【 以下文字转载自 Stock 讨论区 】
发信人: MB80528 (肥猫(Contrarian)[食MM而肥]), 信区: Stock
标 题: Re: CTE halted today
发信站: BBS 未名空间站 (Wed Aug 17 20:36:03 2011, 美东)
......................
中概基本就是墙街的ATM。
中国公司得个虚幻的面子,
墙街轻松插管吸血得银子。
双方各取所需,皆大欢喜。
中概价格波动实况如下。
SYMBOL DATE PRICE FORECAST1 PERCENT1 FORECAST2 PERCENT2
CTE, 20110816, 2.3500, 0.3612, 15.4, -0.0053, -0.2,
CTE, 20110815, 3.9900, -1.8662, -46.8, -1.7919, -44.9,
CTE, 20110812, 3.8500, -0.1256, -3.3, -0.1914,... 阅读全帖 |
|
M*****8 发帖数: 17722 | 3 【 以下文字转载自 Stock 讨论区 】
发信人: MB80528 (肥猫(Contrarian)[食MM而肥]), 信区: Stock
标 题: Re: CTE halted today
发信站: BBS 未名空间站 (Wed Aug 17 20:36:03 2011, 美东)
......................
中概基本就是墙街的ATM。
中国公司得个虚幻的面子,
墙街轻松插管吸血得银子。
双方各取所需,皆大欢喜。
中概价格波动实况如下。
SYMBOL DATE PRICE FORECAST1 PERCENT1 FORECAST2 PERCENT2
CTE, 20110816, 2.3500, 0.3612, 15.4, -0.0053, -0.2,
CTE, 20110815, 3.9900, -1.8662, -46.8, -1.7919, -44.9,
CTE, 20110812, 3.8500, -0.1256, -3.3, -0.1914,... 阅读全帖 |
|
M*****8 发帖数: 17722 | 4
......................
中概基本就是墙街的ATM。
中国公司得个虚幻的面子,
墙街轻松插管吸血得银子。
双方各取所需,皆大欢喜。
中概价格波动实况如下。
SYMBOL DATE PRICE FORECAST1 PERCENT1 FORECAST2 PERCENT2
CTE, 20110816, 2.3500, 0.3612, 15.4, -0.0053, -0.2,
CTE, 20110815, 3.9900, -1.8662, -46.8, -1.7919, -44.9,
CTE, 20110812, 3.8500, -0.1256, -3.3, -0.1914, -5.0,
CTE, 20110811, 4.1600, -0.2290, -5.5, -0.4487, -10.8,
如上所示,8月11日墙街开始沽空CTE。
8月15日天量的沽空CTE,预设CTE惨跌。
8月16日CTE如墙街的精心预先安排... 阅读全帖 |
|
y****w 发帖数: 3747 | 5 滥用CTE,把整个过程逻辑都一层层放到cte里面了。连最普通的源表上project逻辑都要
用一层cte包起来。我数了数大概一个sql语句用了30-40层。
那一块不重要,性能好十倍差十倍也没关系,边边角角,不然肯定打回去让他重写了。
我都怀疑是不是老印们都一个培训班毕业的,好几个都这个风格。估计都是当初被填鸭
了,面试的时候可以振振有词的讲:1)精通cte 2) 1-sql solution. 听起来还是蛮牛
的。 |
|
B*****g 发帖数: 34098 | 6 ***既然是授渔,那就没有鱼,要鱼的请绕行.***
首先,这类复杂sql问题,建议大家用CTE(和Recursive无关),每一步都分开,思路会
清晰得多
with t1 as(
select ....
from ....),
t2 as (
select...
from t1, .....),
....
select
from tn
用过oracle connect by的同学,Recursive CTE实现了类似功能,而且是ansi的,推荐
大家使用,当然,本题用connect by也可以
对于解决本题,思路和用Analytic Functions类似,就是要达到排序后分组的目的,以
原题数据为例,如果有以下标记,用group by user,标记值可得到min(startdate),
max(enddate)即可
User StartDate EndDate 标记值
1 12/2/2011 1/16/2012 0
1 3/4/2012 3/24/2012 1
1 4/5/2012 4/26/2012 1
1 5/14/2012 6/7/2012 1
2 3/5/2012 7/30... 阅读全帖 |
|
y****w 发帖数: 3747 | 7 如上面有兄弟说的,cte最重要的用途还是在recursive。如果只是一个扩展易用版的
subquery,就没太大必要了。这也是为什么说oracle以前的cte也就是应付差事,聊胜于无了。 多数情况下,temp table太重量级,不方便,好比拿c去拼java了。
btw,我相信即使在oracle中,recursive CTE也会取代connect by的地位; 新应用的话能少用就少用,connect by早晚deprecated。就好比rbo特色了太久,回头best practice还是大家都用的cbo。 |
|
s**********0 发帖数: 266 | 8 我觉得CTE最大的好处是你可以用recursive CTE。 一般来说如果有一段code要重复用
的话我都会直接建一个View。 (或者丢到table variable或temp table 里去) |
|
y****w 发帖数: 3747 | 9 作为subquery替代功能,我倾向于相信CTE会抑制optimizer的改写(xx to some JOIN,
etc.)逻辑,强制生成中间临时表。没验证过。
另外,CTE降低了复杂多重子查询的书写难度,更自然,因为可以更多thinking in
prodedure than in set. |
|
g***l 发帖数: 18555 | 10 CTE就是扔在内存的TEMP TABLE,而且是只读的,没有INDEX一样PEFORM很差,关键还是
JOIN的时候要有INDEX,逻辑要清楚,不产生不必要的中间数据,如果SP中间太复杂,
CTE太多,就要考虑用SUMMARY TABLE,提前用JOB ROLLUP,否则RUN一下要几十分钟,
根本没法用。 |
|
m**x 发帖数: 1084 | 11 监狱里自杀了。死后脑解刨,grade 3 CTE. |
|
m**x 发帖数: 1084 | 12 那些打球孩子的家长肯定关心。
断个胳膊,腿还能养好,脑损伤那可不是玩的。看来college, high shcool就已经会脑
损伤了。
nfl球员没几个,可是打college, high shcool可多了。CTE岁数大了得Parkinsons ,
dementia的比例 比一般人的比例高好几倍。 |
|
j*****n 发帖数: 1781 | 13 近日写了一个比较复杂的query. 用了SQL Server 2005 提供的CTE.
由于这个query经常要用到,而且想着SP is pre-complied, 所以就建了一个SP。
谁想在SSMS里面几分钟就能出的结果,SP愣花了半小时也出不了结果...
有哪位碰到过类似的问题么? |
|
B*****g 发帖数: 34098 | 14 以前传说只用sql的是大牛,所以cet套sub,sub再套cte,性能也不见的就好。 |
|
y****w 发帖数: 3747 | 15 cte套多了性能肯定不好。现在的dbms大多不够聪明能够自动给join列加个索引再跑。有时候也怀疑这些做引擎的家伙们缺少field经验。
我是比较喜欢pure sql solution的,能用sql sp就用sql sp,不够用了再去借用java甚至c一下。不过这玩意儿也严重和应用性质有关系,自产自用也就算了,要是deliver给客户呢,怎么保护ip就是一个大问题,比如你辛辛苦苦搞一套db监控软件,不注意保护的话人家好点的dba轻轻松松把你的sql都给抠出来了。
我也只是客串过半年的db developer,经验有限的很,还是在旁边动嘴多一些。 beijing你多讲讲。 |
|
y****w 发帖数: 3747 | 16 re recursive. 我说起cte来一般就默认recursive。。。 刚才beijing在另一个帖子里说的同一个subquery在一个sql里面被引用多次,那也是个常见用法。
建view,很多developer/application不会有权限的。如果在很多地方用到,那是个好的view candidate. 如果只是在一个地方用多次,dba大概不会太高兴手下的schema又复杂了一点。 |
|
g***l 发帖数: 18555 | 17 CTE只是用来替代复杂的SUBQUERY,临时放在内存里,用完就扔掉,如果要反复用的话
,还是建个TEMP TABLE |
|
n*w 发帖数: 3393 | 18 sql server 上的非递归cte应该和subquery更接近吧。如果不是等同。
和temp table应该完全不同。 |
|
|
z**********8 发帖数: 2049 | 20 WITH VacUpdateHeir (EmployeeID, VacationHrs)
AS
(SELECT e.EmployeeID, e.VacationTime
FROM HR.Employees AS e
WHERE e.ManagerID = 30
UNION ALL
SELECT e.EmployeeID, e.VacationTime
FROM HR.Employees as e
JOIN VacUpdateHeir AS v
ON e.ManagerID=v.EmployeeID)
UPDATE HR.Employees
SET VacationTime=VactationTime *1.25
FROM HR.Employees AS e
JOIN VacUpdateHeir As v
ON e.EmployeeID=v.EmployeeID;
这个result set是啥? 为何用recursive CTE? 迷茫。谢谢 |
|
s**********o 发帖数: 14359 | 21 从MANAGER 30找起,一直找到最底层的EMPLOYEE,然后所有MANAGER 30管的EMPLOYEE,
VACATION都乘以1.5,RECUR CTE容易出错的,慎用啊 |
|
y****w 发帖数: 3747 | 22 recursive cte就是sql里面的dfbb。 至少十年老的东西依然可以卖很好的价钱。 |
|
h****t 发帖数: 22 | 23 由于CTE query 的结果需要重复使用,目前将结果保存在表里,通过trigger来更新表
。由于相关表会经常更新,导致结果表跟随着更新,多多少少带来性能上的影响。不知
能够实现在query结果表时才进行重新计算(如果相关表修改过了)。请各位高人提供
思路,谢谢! |
|
s**********o 发帖数: 14359 | 24 CTE recursive query, trigger这些对PERFORMANCE影响很坏的,
有时候会产生你意想不到的结果,为什么老要更新呢?能不能
搞成SCHEDULED JOBS呢,如果必须不断更新,考虑所有应用程序和
QUERY的SELECTION都用WITH (NOLOCK) |
|
T**********e 发帖数: 29576 | 25 慢性脑损伤CTE原来只能通过尸检确定,运动员们没法告赔偿,现在退役了还能告NFL老
板再捞一笔,owner们赶紧下跪吧。
There’s been a monumental breakthrough in CTE research
Doctors at Boston University believe they have discovered a way to diagnose
the brain disease chronic traumatic encephalopathy in living humans, TSN
reported Tuesday. Researchers at BU studied the brains of 23 former football
players, 50 non-athletes with Alzheimer’s and 18 non-athletes.
“The findings of this study are the early steps towards identifying CTE
during life,” said Ann ... 阅读全帖 |
|
f*******h 发帖数: 53 | 26 Try this one, in sqlserver 2008:
;with cte as (
select 1 as GroupID,DAY,opentime,closetime
from OfficeHours
where DAY=1
union all
select cte.GroupID,o.Day,o.OpenTime,o.CloseTime
from cte,
OfficeHours as o
where o.Day=cte.Day+1
and cte.CloseTime=o.CloseTime
and cte.OpenTime=o.OpenTime
union all
select cte.GroupID+1,o.Day,o.OpenTime,o.CloseTime
from cte,
OfficeHours as o
where o.Day=cte.Day+1
|
|
r*s 发帖数: 2555 | 27 Brain damage was diagnosed in 87 percent of donated brains of 202 football
players, including all but one of 111 brains of National Football League
athletes.
This new study, published today in the journal JAMA, is the latest linking
dangerous head injuries to football, though the authors note that the true
risk may be lower than the results suggest.
Chronic traumatic encephalopathy, or CTE, is the term for brain damage that
occurs after repeated blunt impact, like head tackles in football. Previ... 阅读全帖 |
|
i****a 发帖数: 36252 | 28 basic idea is to use row_number and self joining tables. if you use CTE,
here is an example
with cte as
(
select ROW_NUMBER() over (order by tb1.colDate) as rn1, *
from tableTest2 tb1
)
select *
from cte
inner join (select ROW_NUMBER() over (order by colDate) as rn2, * from
tableTest2) tb2
on cte.rn1 = tb2.rn2 - 1 and cte.attr <> tb2.prev
if you don't want to use CTE or not on SQL server 2005 or later, then put
result from the 1st query into a temp table |
|
W*****B 发帖数: 4796 | 29 Aaron Hernandez Diagnosed with 'Severe' Form of CTE
Get your team's alerts, highlights, and stories first
GET THE B/R APP
Former New England Patriots tight end Aaron Hernandez was diagnosed with a &
#34;severe" form of chronic traumatic encephalopathy (CTE) in an
evaluation following his death from an apparent suicide in April.
Per Ken Belson of the New York Times, lawyer Jose Baez announced
the results Thursday, stating research concluded Hernandez had "the most
severe c... 阅读全帖 |
|
W*****B 发帖数: 4796 | 30 【 以下文字转载自 Military 讨论区 】
发信人: WCNMLGB (CCC), 信区: Military
标 题: 慢性创伤性脑病 - 打橄榄球的同学注意下
发信站: BBS 未名空间站 (Thu Sep 21 17:10:11 2017, 美东)
Aaron Hernandez Diagnosed with 'Severe' Form of CTE
Get your team's alerts, highlights, and stories first
GET THE B/R APP
Former New England Patriots tight end Aaron Hernandez was diagnosed with a &
#34;severe" form of chronic traumatic encephalopathy (CTE) in an
evaluation following his death from an apparent suicide in April.
Per Ken Belson of the Ne... 阅读全帖 |
|
m*********y 发帖数: 389 | 31 Here are some questions I copied from online.. Obviously LouZhu is a lazy
ass... these questions are everywhere... :-)
SQL Interview questions
Below is a list of questions in this blog post so you can test your
knowledge without saying answers. If you would like to see questions and
answers please scrool down.
Question: What type of joins have you used?
Question: How can you combine two tables/views together? For instance one
table contains 100 rows and the other one contains 200 rows, have exac... 阅读全帖 |
|
t****n 发帖数: 10724 | 32 *******************************************************************
HR SQL难题的三种解法
*******************************************************************
摘要
本文综合描术了针对养老院人事难题的多种SQL解法。
鸣谢
Beijing
===========================================================
解法1 -- Partition 法
===========================================================
可以参考wyr解法,本解法用了lead/lag,以及ROWS UNBOUNDED PRECEDING A... 阅读全帖 |
|
f*******h 发帖数: 53 | 33 来自主题: JobHunting版 - 问道sql SQL SERVER CTE:
with cte as(
select empid
from employess
where empid=34
union all
select e.empid
from employess as e
where e.supervisor=cte.empid
)
select * from cte |
|
y****w 发帖数: 3747 | 34 "以前的CTE就是摆设,只有到11r2还是多少才完善起来"
俺没说以前没有CTE阿,好吧,没强调recursive,虽然一般说起cte俺suppose就是recursive的,不然和subquery除了写法没啥区别。
oracle community还是习惯于connect by,但是从其他数据库过来的会更喜欢recursive CTE。
server/db2 can be convert to oracle, but can not convert oracle to others,
hehe |
|
g***l 发帖数: 18555 | 35 CTE就是在内存里暂时存一下,尤其是这种自己UPDATE自己的,搞不好就乱套,写到
TABLE里存进DISC,一般是这样用CTE的,记住是在内存里,随用随扔,如果要UPDATE CTE就再产生一个CTE,扔掉以前那个,
;WITH CTE_1
(
SELECT BLAH BLAH
FROM
TABLE A
),
CTE_2
(
SELECT BLAH BLAH
FROM
CTE_1
JOIN OTHERS
),
CTE_3
(
SELECT BLAH BLAH
FROM
CTE_2
JOIN ...
),
UPDATE
TABLE A
FROM
CTE_3
WHERE |
|
c****t 发帖数: 265 | 36 谢谢楼上各位,今天与系主任谈了谈,受益良多,与大家分享一下
系主任说,他从来不是非常看重CTE,一方面,我们毕竟还要做research要平衡两个。
另一方面,他觉得每个人都有自己的教学方法和准则,如果单纯为了高分,而牺牲一些
东西非常不值得。如果为了高分,把学生当成clients一样去serve,其实对学生不好。
对学生要求严一些,或许CTE不会太高,但是是认真负责的做法。还有一些老师与学生
关系很好,下课会一起吃饭,这样也不错,但是容易形成小团体。任何事情都要理智客
观的判断。他绝对不会太看重CTE,相信我们老师自己教学,对得起学生,对得起自己
,就好了。
觉得我们系主任真是英明,哈哈 |
|
w********9 发帖数: 8613 | 37 http://www.cnn.com/2015/09/18/health/nfl-brain-study-cte/
87 of 91 tested (self-selected) ex-NFL players had brain disease linked to
head trauma
The study results don't necessarily mean that 96% of all NFL players are at
risk for CTE, said Dr. Robert Cantu. The brains came from players who, while
they were alive, had concerns about CTE. His group began its work in 2008. |
|
t******l 发帖数: 10908 | 38 楼上说了,藤校主要是看体育,体育不行就算了,反正藤校本质上可能就是少体校。//
run
当然换了我觉得少体校真心没必要去就是了,特别是自费。我是不会让娃冒 CTE 或磨
损身体的风险去搞竞技体育的。CTE 损毁长期 mental health,短期看不出来,现代技
术在人活着的时候都没法查 CTE。
:或者证明,被录取的那些获奖者,没有比这个奖更有价值的其他成绩。 |
|
l*****y 发帖数: 4887 | 39 还真不是,这个研究用了202个捐赠的脑子,
其中有111个NFL退役球员,另外的比如只打过大学比赛的
CTE比例也很高了,48/53(91%)
捐赠的里面白人占大多数,所以位置上看,其实OL很不少
招到且确诊CTE的里面
37个OL,其中29个是严重的CTE
35个DL,27个严重
31个RB,27个严重
13个QB,11个严重(看起来QB都是重灾区了)
26个LB,14个严重
只有4个WR(估计是没招到)
比较好的是Kicker,确诊的也都是轻微的,不让roughing the kicker还是有效的
他们好像没有公布不同位置的发病率,
但是在NFL-level,已经基本上是100%发病,也没必要说了。
看发病之后的症状严重的比例,OL/DL也非常不乐观
R |
|
B*****g 发帖数: 34098 | 40 I use CTE in oracle 9i/10g/11g, never have any problem.
But most important thing to remember is oracle use CBO, when you use CTE
does not mean oracle will run the CTE part first, oracle may still choose
other execution plan. |
|
i****a 发帖数: 36252 | 41 如果我從 CTE 做 UPDATE, for example:
;with CTE as
(select columnA
, row_number() over (order by columnB) as row_num
from TableA
)
Update C
SET columnA = 'testing'
from CTE C
where row_num < 10
Question is, will the query pull all records from TableA, or only 10 rows
with row_num < 10? |
|
g***l 发帖数: 18555 | 42 CTE就不能UPDATE吧,反正我从不UPDATE CTE,就跟VIEW一样,一旦产生了就不能改了
,而且是用完就扔。你的这个用TABLE VARIABLE会好一些,
Common Table Expressions, or CTE, are a new construct introduced in
Microsoft SQL Server 2005 that offer a more readable form of the derived
table that can be declared once and referenced multiple times in a query. |
|
y****w 发帖数: 3747 | 43 多层的Cte 没几个能update的 术语:updatable view
CTE就再产生一个CTE,扔掉以前那个, |
|
g**1 发帖数: 10330 | 44 https://www.washingtonpost.com/news/early-lead/wp/2016/09/12/the-man-who-
discovered-cte-thinks-hillary-clinton-may-have-been-poisoned/
The man who discovered CTE thinks Hillary Clinton may have been poisoned
Putin, as The Washington Post reported, was implicated by a British inquiry
in January in the poisoning death of Alexander Litvinenko, a former KGB
operative, in London in 2006. The Post’s Griff Witte and Michael Birnbaum
wrote at the time:
Although the inquiry stops short of conclusively b... 阅读全帖 |
|
g***j 发帖数: 40861 | 45 【 以下文字转载自 Joke 讨论区 】
发信人: rbs (jay), 信区: Joke
标 题: NFL球员去MIT读数学博士
发信站: BBS 未名空间站 (Thu Jul 27 15:20:18 2017, 美东)
Baltimore Ravens offensive lineman John Urschel surprisingly retired from
the NFL on Thursday at the age of 26.
According to CNN's Jill Martin, Ravens head coach John Harbaugh was informed
of the decision on Thursday and released the following statement on Urschel
the past three years and wish him all the best in his future endeavors."
A source told ESPN's Jamison Hensley that the res... 阅读全帖 |
|
l******9 发帖数: 579 | 46 On SQL server 2008, I need to get a new table by selecting two columns from
two different tables.
address (from another_table) id_num (from a cte created by me)
city_1 65
city_1 36
city_2 65
city_2 36
city_3 65
city_3 36
Suppose that id_num has only 65 and 36 two values. The cte has no column of
"address". the another_table has no column of id... 阅读全帖 |
|
t******l 发帖数: 10908 | 47 老实说目标是体育锻炼健身角度而言,说专业技术就是扯。。。专业技术对基本
的健身不仅没多大用,而且大幅度增大 Concussion / TBI / CTE 的概率倒是,
因为速度和冲击都上来了。。。这还没算上竞技对身体的 wear out。。。当然
人练技术是因为想去 varsity team 玩,图开心,school life,另说。
现在没有 Concussion / TBI / CTE 是因为在三年级,离开 puberty 还远。
到六年级女生,100 米的前四名都跑进 15 秒,跳远的前几名都跳到 13+ feet,
那时再讲 TBI。
而且你说的 “三年级小姑娘的篮球比赛秒杀我们当年高中大学女子篮球赛(非专业队
)”,你大学如果愿意按现在小学生的练法,练上三年,肯定不会比小学三年级小姑
娘差。(当然前提是 body 足够 fit)。。。否则就是记忆被修改。。。
playground |
|
t******l 发帖数: 10908 | 48 当然版上 12 岁 decay 点以前,既不是 varsity 牛校队,也不是牛鼻 travel team
的,就不要担心 CTE 了。乌龟撞乌龟是撞不出 CTE 的,天天撞也撞不出来的。
:楼上说了,藤校主要是看体育,体育不行就算了,反正藤校本质上可能就是少体校。
// run
: |
|
|
b*********n 发帖数: 5846 | 50 CTE of aluminum: 13.1
CTE of copper: 9.8 |
|