51Testing软件测试论坛

标题: sql语句,求最大值,最小值,平均值 [打印本页]

作者: 测试积点老人    时间: 2020-10-23 10:17
标题: sql语句,求最大值,最小值,平均值
  1. SELECT *
  2. FROM
  3. (
  4. SELECT
  5. t1.broker_id,t1.broker_name,t2.thscode,t2.sec_id,sec_type,
  6. t2.is_listing,t2.listed_status_code,t2.listed_status,t2.td_mkt,t2.sec_short_name_cn
  7. FROM ashare_broker_monthly_report t1 INNER JOIN sec_basic_info t2
  8. ON t1.broker_id = t2.issue_org_id
  9. where listed_status_code ='213001'
  10. AND is_listing =1
  11. AND td_mkt_encode in ('212001','212100')
  12. AND sec_type = 'A股'
  13. GROUP BY t1.broker_id,t1.broker_name,t2.thscode,t2.sec_id
  14. ) m
  15. INNER JOIN
  16. (
  17. SELECT dt,sec_type,sec_id, pe_ttm_ed 'PE_TTM(截止日期)',pb_lastest_ed 'PB_最新(截止日期)'
  18. FROM stock_ttm_valuation_index
  19. WHERE sec_type = 'A股' AND dt >= '2020-08-10' AND dt < '2020-08-17'
  20. GROUP BY dt,sec_type,sec_id
  21. ORDER BY dt DESC
  22. ) n
  23. 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