我有一个SQL Server查询:
SELECT MD.Author_ID, MD.CoAuthor_ID, ACP.Probability [AC_Probability],
MD.Venue_ID, AVP.Probability [AV_Probability], A2P.pid [Paper_ID],
P.abstract_research_area_category_id [Paper_Category_ID],
MD.Paper_Count, MD.Year
FROM Merged_Data MD
JOIN sub_aminer_author2paper A2P ON MD.Author_ID = A2P.aid AND
MD.Year = A2P.p_year AND
MD.Venue_ID = A2P.p_venue_vid
JOIN sub_aminer_paper P ON MD.Venue_ID = P.p_venue_vid AND
MD.Year = P.p_year
JOIN AuthorCoAuthorProbability ACP ON MD.Author_ID = ACP.Author_ID AND
MD.CoAuthor_ID = ACP.CoAuthor_ID AND
MD.Year = ACP.Year
JOIN AuthorVenueProbability AVP ON MD.Venue_ID = AVP.Venue_ID AND
MD.Author_ID = AVP.Author_ID AND
MD.Year = AVP.Year
WHERE MD.Author_ID = 677 AND
P.abstract_research_area_category_id IS NOT NULL AND
A2P.pid = P.pid
给我结果如下:
我想在P_Probability
列之前的末尾添加另一列Year
,例如:
对于Year = 2005
,Author_ID = 677
在8
列中有11
,12
和Paper_Category_ID
,而3
中有Paper_Count
1}}列,每个Year
每个Author_ID
最多有3行(如果存在)。
因此P_Probability
列中的值应为:
8
对677
/ 2005
= Paper_Count
= 1/3
的{3}行的{3}行中存在0.333333333333333
的次数
11
对677
/ 2005
= Paper_Count
= 1/3
的{3}行的0.333333333333333
次存在的次数
12
对677
/ 2005
= Paper_Count
= 1/3
0.333333333333333
次的次数
换句话说,P_Probability
计算概念是:
DISTINCT Paper_Category_ID
中Author_ID
的{{1}}除以Year
中的Paper_Count
除以Year
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${host}"/>
<property name="port" value="${port}"/>
<property name="username" value="${mail.username}"/>
<property name="password" value="${mail.password}"/>
<property name="javaMailProperties">
<props>
<!-- Use SMTP transport protocol -->
<prop key="mail.transport.protocol" >${mail.transport.protocol}</prop>
<!-- Use SMTP-AUTH to authenticate to SMTP server -->
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
<!-- Use TLS to encrypt communication with SMTP server -->
<prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable}</prop>
<prop key="mail.debug">false</prop>
<prop key="mail.smtp.ssl.enable">true</prop>
</props>
</property>
</bean>