Skip to content
Advertisement

Tag: sql

Double quotes problems with Postgres

I am using Django with postgres. Here’s the snippet of my code which I am using to create tables in the db. My question is: why is the user table getting renamed as “user” (with quotes) why is the role_id getting named as role_id_id where as I have clearly mentioned role_id to be my column name? Answer After reading few

How to cast varchar on update?

When I update t1 then “VALUE” field should increment but this field is set to VARCHAR and I would cast it to INTEGER: Answer You will need to cast “VALUE” to an integer to be able to increment it, so: Firebird will automatically convert the INTEGER back to a VARCHAR on assignment. See this dbfiddle. That said, the proper way

Group rows on condition PostgreSQL

I have a table with repeated Column1 and Column2 pairs, let’s say this is ‘many-to-many’ table. Also, I have there one extra integer column – Column3. What I want is select conditionally grouped rows, like 1). If pair of Column1 and Column2 have several records contains 5 value among others – then it should be grouped into one row with

Advertisement