L
L
lukoie2021-12-23 18:18:33
SQL
lukoie, 2021-12-23 18:18:33

How to force integer when forming a view in SQLite?

Hello. There is a database with voting data.
Separate tables with: 1) projects 2) project authors 3) categories 4) votes by day - the last one is our main work data:

spoiler
61c48f81da375141855034.png

all fields are of type integer.
I make a view with the difference in votes by day:
SELECT
  project_votes.project_number AS "Номер проєкту",
  CAST(project_votes."15.12.2021"-project_votes."13.12.2021" AS INTEGER) AS "Четвер",
  project_votes."17.12.2021" - project_votes."15.12.2021" AS "Пятниця",
  project_votes."18.12.2021" - project_votes."17.12.2021" AS "Субота",
  project_votes."19.12.2021" - project_votes."18.12.2021" AS "Неділя",
  project_votes."20.12.2021" - project_votes."19.12.2021" AS "Понеділок",
  project_votes."21.12.2021" - project_votes."20.12.2021" AS "Вівторок",
  project_votes."21.12.2021" AS "Станом на зараз",
  projects.content_short AS "Короткий опис" 
FROM
  project_votes
  INNER JOIN projects ON project_votes.project_number = projects.project_number 
ORDER BY
  project_votes."21.12.2021" DESC

And I get an output with a difference in days.
spoiler
61c4901614160973336358.png

As a result, I need to get a graph like this
spoiler
61c49a7f4a0dc582410299.png

BUT along the way, when generating the output of the view, the fields with arithmetic do not receive the type of the field. Therefore, they are recognized as varchar (underlined in blue the results of subtraction) and not int:
spoiler
61c4914bb0f21724717316.png

Hence the question - how can one forcefully indicate when forming a view that the output column has a numeric type?
Because with the text type it will not be possible to make the sum of the values, and as a result it will show on the graph only the number of records themselves.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question