0

I have two SQLite tables (companies and complaints) I'm using to calculate a ratio of HR complaints to employees, but when attempting to run the query below in DB Browser, I'm getting this error:

-- Result: no such column: complaints.hrcomplaints

Here's the SQL I'm using:

CREATE TEMPORARY TABLE newratio AS SELECT companies.uniqueID, employees, complaints.hrcomplaints,
       (ROUND(hrcomplaints * 100.0 / employees, 1)*.01) AS newratio
FROM companies
ORDER BY newratio

The column type for both hrcomplaints and employees is integer. I'm not seeing any extra whitespace in the column names when viewing the DB structure.

Marcatectura
  • 1,721
  • 5
  • 30
  • 49
  • What is the relation between companies and complaints? Post the definitions of the tables. – forpas Apr 25 '21 at 19:53
  • @forpas, there is no relationship (primary key etc) between tables - I'm pretty new to SQL, is that what you are asking? – Marcatectura Apr 25 '21 at 19:56
  • There should be a relationship. Tables consist of rows and columns. Which column value of hrcomplaints from complaints will be divided by which column value of `employees` (which is also not clear in which table it belongs)? – forpas Apr 25 '21 at 20:04

0 Answers0