duplicate-removal

Sybase SQL - Remove “semi-duplicates” from query results

元气小坏坏 提交于 2019-12-25 01:35:07
问题 I have a query that uses two SELECT statements that are combined using a UNION ALL . Both statements pull data from similar tables to populate the query results. I am attempting to remove the "semi-duplicate" rows from the query, but am having issues doing so. My query is the following: SELECT DISTINCT * FROM ( SELECT TeamNum = CASE WHEN T.TeamName = 'Alpha Team' THEN '1' WHEN T.TeamName IN ('Bravo Team', 'Charlie Team') THEN '2' WHEN T.TeamName = 'Delta Team' THEN '3' ELSE '<Undefined>' END,

Delete duplicate rows (don't delete all duplicate)

≡放荡痞女 提交于 2019-12-25 01:26:53
问题 I am using postgres. I want to delete Duplicate rows. The condition is that , 1 copy from the set of duplicate rows would not be deleted. i.e : if there are 5 duplicate records then 4 of them will be deleted. 回答1: Try the steps described in this article: Removing duplicates from a PostgreSQL database. It describes a situation when you have to deal with huge amount of data which isn't possible to group by . A simple solution would be this: DELETE FROM foo WHERE id NOT IN (SELECT min(id) --or

Excel: Pair things up between two columns (A and B), and show unpaired values in columns C and D

一笑奈何 提交于 2019-12-25 01:17:13
问题 Excel buffs: There are many results showing up when searching for comparisons between two columns (ie: using VLOOKUP) but none of the results I have looked so far seems to do what I need in this particular way: Column A has following values: Z, Q, V, V, T, T Column B has following values: V, T, T, M Column C will display Z, Q, V (here we have one V because one set of 'V' pairs up, leaving us with one unpaired 'V') Column D will display M The other examples I've seen so far assumes Column C

Keep first of duplicate records and delete the rest

别说谁变了你拦得住时间么 提交于 2019-12-25 00:38:15
问题 This question does pretty much what I want to accomplish, but my table is more complicated and does not have a primary key. I also don't quite understand the top answer, what the t1 and t2 mean. If this answer can be applicable to me, would appreciate if someone explain the code. I have several months' tables that contain info on clients and the policies they hold. Every client has a unique policy ID, but they can have multiple policies, resulting in multiple records under the same policy ID.

Show only last duplicates in access query

◇◆丶佛笑我妖孽 提交于 2019-12-24 12:34:55
问题 I have a database in access where I log maps which I loan out. So I have a table called MapsOut, with fields, MapNum(The map ID), MapName (Name of the Map), CheckOut (Date the Maps were loaned out), CheckIn (Date the Maps were returned). MapNum MapName CheckOut CheckIn 1 London 01/02/13 07/05/13 1 London 08/05/13 16/06/13 1 London 19/07/13 2 Hull 30/01/13 05/03/13 2 Hull 06/04/13 01/05/13 3 Derby 11/01/13 17/02/13 3 Derby 05/09/13 06/10/13 4 Hove 01/02/13 01/03/13 I want to write a query that

sql select 3 columns and dedupe on two columns

偶尔善良 提交于 2019-12-24 07:24:25
问题 I have a job setup that currently selects records from a table that does not contain a unique index. I realize this could be solved by just putting an index on the table and the relevant columns but, in this scenario for testing purposes, I need to remove the index and then do a select which will also remove duplicates based on 2 columns: SELECT DISTINCT [author], [pubDate], [dateadded] FROM [Feeds].[dbo].[socialPosts] WHERE CAST(FLOOR(CAST(dateadded AS float)) AS datetime) > DATEADD(DAY,

sql select 3 columns and dedupe on two columns

一个人想着一个人 提交于 2019-12-24 07:23:08
问题 I have a job setup that currently selects records from a table that does not contain a unique index. I realize this could be solved by just putting an index on the table and the relevant columns but, in this scenario for testing purposes, I need to remove the index and then do a select which will also remove duplicates based on 2 columns: SELECT DISTINCT [author], [pubDate], [dateadded] FROM [Feeds].[dbo].[socialPosts] WHERE CAST(FLOOR(CAST(dateadded AS float)) AS datetime) > DATEADD(DAY,

sql select 3 columns and dedupe on two columns

杀马特。学长 韩版系。学妹 提交于 2019-12-24 07:23:07
问题 I have a job setup that currently selects records from a table that does not contain a unique index. I realize this could be solved by just putting an index on the table and the relevant columns but, in this scenario for testing purposes, I need to remove the index and then do a select which will also remove duplicates based on 2 columns: SELECT DISTINCT [author], [pubDate], [dateadded] FROM [Feeds].[dbo].[socialPosts] WHERE CAST(FLOOR(CAST(dateadded AS float)) AS datetime) > DATEADD(DAY,

PostgreSQL: LEFT JOIN creates blank row

情到浓时终转凉″ 提交于 2019-12-24 05:30:26
问题 See important new discoveries 1 and 2 at end of this explanation. I am running Postgres 9.1.3 and am having a weird left join issue. I have a table named consistent.master with over 2 million rows. It has a column named citation_id , and that column has no nulls. I can verify that with this: SELECT COUNT(*) FROM consistent.master WHERE citation_id IS NULL That returns 0 . Here's where it gets weird: if I LEFT JOIN this table to a temporary table, I get an error that I am trying to insert a

PostgreSQL: LEFT JOIN creates blank row

与世无争的帅哥 提交于 2019-12-24 05:30:12
问题 See important new discoveries 1 and 2 at end of this explanation. I am running Postgres 9.1.3 and am having a weird left join issue. I have a table named consistent.master with over 2 million rows. It has a column named citation_id , and that column has no nulls. I can verify that with this: SELECT COUNT(*) FROM consistent.master WHERE citation_id IS NULL That returns 0 . Here's where it gets weird: if I LEFT JOIN this table to a temporary table, I get an error that I am trying to insert a