51Testing软件测试论坛
标题:
sql语句,求最大值,最小值,平均值
[打印本页]
作者:
测试积点老人
时间:
2020-10-23 10:17
标题:
sql语句,求最大值,最小值,平均值
SELECT *
FROM
(
SELECT
t1.broker_id,t1.broker_name,t2.thscode,t2.sec_id,sec_type,
t2.is_listing,t2.listed_status_code,t2.listed_status,t2.td_mkt,t2.sec_short_name_cn
FROM ashare_broker_monthly_report t1 INNER JOIN sec_basic_info t2
ON t1.broker_id = t2.issue_org_id
where listed_status_code ='213001'
AND is_listing =1
AND td_mkt_encode in ('212001','212100')
AND sec_type = 'A股'
GROUP BY t1.broker_id,t1.broker_name,t2.thscode,t2.sec_id
) m
INNER JOIN
(
SELECT dt,sec_type,sec_id, pe_ttm_ed 'PE_TTM(截止日期)',pb_lastest_ed 'PB_最新(截止日期)'
FROM stock_ttm_valuation_index
WHERE sec_type = 'A股' AND dt >= '2020-08-10' AND dt < '2020-08-17'
GROUP BY dt,sec_type,sec_id
ORDER BY dt DESC
) n
ON m.sec_id = n.sec_id ;
复制代码
[attach]130320[/attach]
改这个sql,才能求出红色框中的那个值的最大值,平均值
作者:
bellas
时间:
2020-10-26 10:09
参考下这个链接
https://www.cnblogs.com/wushuo-1992/p/8370510.html
作者:
海海豚
时间:
2020-10-26 10:11
https://www.csdn.net/gather_24/M ... xvZwO0O0OO0O0O.html
看下这个
作者:
郭小贱
时间:
2020-10-26 10:30
参考这篇博文看下呢
https://www.cnblogs.com/wushuo-1992/p/8370510.html
作者:
qqq911
时间:
2020-10-26 10:34
按倒序排列第一条
作者:
jingzizx
时间:
2020-10-26 13:26
先注意下格式
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2