Home > database >  Junior apprentices
Junior apprentices

Time:12-28

# recalculation level
SQL="" "
As with TMP (
Select a case when dt=date (' now ') then 20
The when dt>=the date (the 'now', '- 3 day') and dtThe when dt>=the date (the 'now', '- 5 day) and dtThe when dt> Date (' now ', '150 - day') then 5 end as fairly rk
The from v_stock_news where news_type='good'
Union all
Select code, case when dt=date (' now ') then 20
The when dt>=the date (the 'now', '120 - day') then - 5
The when dt>=the date (the 'now', '240 - day') and dtThe when dt> Date (' now ', '240 - day') then - 5 end
The from v_stock_news where news_type='bad'
Union all
Select code, 10 from stock_rk0
), t the as (select code, the sum (fairly rk) fairly rk from TMP group by code)
The update stock_rank set fairly rk=(select fairly rk from t where stock_rank. Code=tc ode)
"" "
Cursor. The execute (SQL)
# copy today good stock to clipboard
C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python38 \ Python exe D:/stock/auto_huatai/spiders. Py
Tip: the current environment pandas version 0.25, get_price with get_fundamentals_continuously interface panel parameters will be fixed to False
Note: pandas above 0.25 version does not support the panel, such as the use of the data structure and related functions please pay attention to modify the
Traceback (the most recent call last) :
The File "D:/stock/auto_huatai/spiders. Py", line 90, in & lt; module>
Cursor. The execute (SQL)
Sqlite3. OperationalError: SELECTs the to the left and right of UNION ALL do not have the same number of result columns

The Process finished with exit code 1
This is stuck in data processing, this is the last step, consult tall person, a reward!

CodePudding user response:

Select a case when dt=date (' now ') then 20
The when dt>=the date (the 'now', '- 3 day') and dtThe when dt>=the date (the 'now', '- 5 day) and dtThe when dt> Date (' now ', '150 - day') then 5 end as fairly rk
The from v_stock_news where news_type='good'

You this result set only one field, and the two result sets are two fields, the number of union all required fields must be consistent,
  • Related