title: Can't convert postgresql table column from type varchar to int
body: <p>I have a database table of that I have used to store the data returned from a web spider. I have a column that contains ticket prices for different events all in the varchar type (as the scrapy spider has to scrape the data in unicode). I'm trying to return the min price of the column and since the min() function only works for data of type INT, I tried to convert the column to integers using a solution from <a href="https://stackoverflow.com/questions/13170570/change-type-of-varchar-field-to-integer-cannot-be-cast-automatically-to-type-i">this SO post</a>:</p>
  <pre><code>ALTER TABLE vs_tickets ALTER COLUMN ticketprice TYPE integer USING (ticketprice::integer);
  </code></pre>
  <p>but I got the error: <em>ERROR:  invalid input syntax for integer:</em></p>
  <p>I also tried: <code>change_column :vs_tickets, :ticketprice, 'integer USING CAST(ticketprice AS integer)'</code> but that didn't work either.</p>
  <p>What is the proper way to convert the column to type INT?</p>
  <h3>Edit:</h3>
  <p><a href="https://i.stack.imgur.com/r8A0K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r8A0K.png" alt="enter image description here" /></a></p>