Skip to content

How to have data in Range column

I have 1 table named Temp1 and Columns are as below. In this table we have to make sure that salary of employee for any designation must be in between TopRange and Bottom Range. So I need to create a …

Postgresql constraint violated at restore

I have a problem with a constraint that is being violated by some rows when restoring my DB, but has never been violated at usage. I have 3 tables : some_table here is another table, which I think is not relevant for this problem. Now what I want is to have a unicity constraint between as.id and bs.some_id th…

How to create a column in SQL containing using the AVG() function?

I have a table with one column and 46 rows and I want to create another column that contains the average of the first column in all 46 rows e.g. This is the table: I want to add another column that contains for each row (46 rows) the value of AVG(column1) How do can it be done? Answer You wouldn’t

Create subqueries for each value in a Column

I’m looking to create a SQL query that answers the following question: “Which was the most common destination airport in each month?” The table is structured such that it has Month and Destination_Airport columns (amongst other things), and I’m hoping for the query result to look like …

Remove duplicate rows from a big table

I’ve got data from third party and imported to SQL server. The table has 255,072,636 records and 61,714,772 are unique among these records. The table has neither specific order nor any index. The table has 4 columns: Field1(float), Field2(varchar(255), Field3(varchar(255), Field4(varchar(255). I want to…

Unexpected results with consecutive + and – [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I have the following queries : The result is : How is this output explained…