Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql postgres使用特定的公式获得特定字段的结果_Postgresql - Fatal编程技术网

Postgresql postgres使用特定的公式获得特定字段的结果

Postgresql postgres使用特定的公式获得特定字段的结果,postgresql,Postgresql,我正在尝试从postgres数据库中获取结果 我的数据在屏幕截图中看起来像这样 我想从仓库\u ticker表格中获得每个股票代码,并附上以下格式 adj_close - (return - adj_close_latest / adj_close_first - 1) adj_close_first是表中本年的第一个日期(date是列名),adj_close_latest是日期列的最晚日期 因此,对于每个股票代码,它将给出结果 所以首先需要找到最新的adj_close_和adj_close_

我正在尝试从postgres数据库中获取结果

我的数据在屏幕截图中看起来像这样

我想从仓库\u ticker表格中获得每个股票代码,并附上以下格式

adj_close - (return - adj_close_latest / adj_close_first - 1)
adj_close_first是表中本年的第一个日期(date是列名),adj_close_latest是日期列的最晚日期 因此,对于每个股票代码,它将给出结果

所以首先需要找到最新的adj_close_和adj_close_的adj_close,然后我们可以把东西放在形式上

结果会是这样

tiker result
AAPL   23
MICR   34
MICR   12
然后,通过分组扇区找到股票代码的平均值 AAPL和MICR属于一个称为技术的部门 我们必须将AAPL、MICR和avg分组