I have a polygon layer named scale_polygons_v4. I want to get ids of overlapping polygons. I have tried the code below:
select distinct s1.id,s2.id from scale_polygons_v4 s1
inner join ...
This question is related to the following 2 SQL errors (line breaks added by me)
Expression #2 of ORDER BY clause is not in SELECT list, references ...
Below is an example of my pricing_supports table have more than 3 milions rows.
There some rows having same values in the first_origin_id, delivery_id fields.
If there're records with same ...
I'm learning how to handle databases, so this is a trivial question, and quite likely has been answered already. I'm just not familiar to the lingo and have no idea how to search for it (although I ...
In MongoDB we have distinct method that returns distinct values of a record from a specific collection:
The above command returns distinct ...
I have a table like this,
CREATE TABLE foo (
INSERT INTO foo (id, col1, col2, col3, col4, col5)
I have a table that has multiple rows associated with each ID but sometimes containing differing info:
Key, ID, Name, Title, Time
4, AA, Abe, NULL, 2018-01-05
3, BB, NULL, Mrs, 2018-...
I have a table t in a database (PostgreSQL 10.4):
Column | Type | Collation | Nullable | Default
Below is an example of my customer table. There some records having multiple values in BIRTHDAY DATE (by mistake or so). I only want to select those records that have same values for LASTNAME, ...
I am trying to return a distinct set of department names from a table - nothing special. However, when using the following query duplicates are displayed:
select distinct department_name
From my understanding, primary keys are unique by definition. If that's true, would one ever want to SELECT DISTINCT on the primary key? Is this ever practical/useful?
How do I insert (or generate and insert) a primary key when I use the SELECT DISTINCT query?
If I have a table made like this:
CREATE TABLE testUser(
username VARCHAR2(50 CHAR),
I would like to merge 3 tables data, each have a number column in common,
but all the other data differs.
What I would like to achieve is selecting all of the data from the common column
and merging ...
I am using the following statement:
I am trying fix some severe performance issues on codechecker. Issue reported here:
The table is the following:
I want to get only rows having a different values in a column(column name DEF) based on the duplicate rows having unique combination of other 3 columns.
Example: In the below example first two rows ...
I am new topsql and am interested in counting the number of unique first time users per day.
My table only has two columns- user_id (there can be multiple uses by one user per day) and start_time ...
I am unclear on exactly on,
SELECT DISTINCT col1, col2, ...
When called on one column it gives back only distinct values of that column. What happens when we use it with multiple ...
I am pretty sure I am making a basic mistake, but I can't figure it out for the life of me. I am trying to get a simple report of total number of unique employees, number of employees who are male, ...
I would like to get the most efficient query to give me all the rows that are distinct on one field (ID) but are identical on another field (validity).
Let's set a concrete example: you have a table ...
I need some assistance and guidance.
I want to retrieve a summary of results based on values in another column.
For example, I have a column in my data set that shows an audit date. There will be ...
Consider the following two queries.
SELECT Col1, Col2
SELECT Col1, Col2
SELECT DISTINCT Col1, Col2
SELECT DISTINCT Col1, Col2
These are ...
How can I retrieve an row with unique value pairs that occur more than once...
Heres an example of what I'm what I am trying to..
COUNT(distinct column_fk_id1, ...
can someone please help me with the below requirement?
I have a table with sample data below
Now, I want to write a query that
1. It don't miss any ID in the report
2. If a particular ID has a ...
I use MySQL 5.6 and 5.7 on Ubuntu 16.04.3 LTS and I have a problem with the following query (which is derived from drupal 7 but have simplified it in order to pinpoint the issue):
select distinct ...
In Mongo 3.4 explain("executionStats").distinct(...), for some queries
the winning plan contains an IXSCAN step, and for other queries it contains an DISTINCT_SCAN step.
What is the difference ...
I'm trying to select the most recent authors of messages in a room, using this (simplified) table:
Column | Type | Nullable | Default ...
Tables have not been created yet, but to simplify there is a groups and an items tables. A group contains an item id (and a group id). And several groups may contain the same item id.
A table has CSV data and I want to do a SELECT DISTINCT ID on that table, how should I proceed?
| id |
| 111,1487 |
| 462 |
I have a table like this :
I want to select all IPs that did search for multiple ...
I have a records table with ~3 million records. The table has a column called record_type with an index.
Column | ...
I've got a query where I want to retrieve distinct Child rows, but ordered by a column of Parent. If I do the following, I get an error because the column specified in the ORDER BY is not included in ...
How do you query for three unique customers with the largest Purchase_Cost?
I want to apply the DISTINCT only on Customer_Name, but the query below applies the distinct on all three columns. How ...
I am currently trying to find distinct combinations within a table as two of the columns have a many to many relationship with each other.
The data is all around backup policies being run on against ...
Supposing we have a table with four columns (a,b,c,d) of the same data type.
Is it possible to select all distinct values within the data in the columns and return them as a single column or do I ...
A query I'd like to be able to run is one where it looks through all of the maintenance logs of our vehicles, finds those where the part is question was used, and then follow it all back to output the ...
We have an ERP system which allows aggregates to be used (eg SUM(foo)) but not with DISTINCT (eg SUM(DISTINCT foo).
Is it possible to create an aggregate function (SUM_DISTINCT), that returns the ...
Just for curiosity, if I have to use rank to tag distinct values for some columns only, and ignore whatever different values occurred on other columns, why not use distinct and just remove the other ...
I'd like to select the most recent row in a MS SQL Server 2008 R2 database based on a couple of factors. I've seen a lot of people want to do the same thing online, and a lot of different proposed ...
I need a select statement which finds values from Column B which occurs in all distinct values for A. Meaning in my example it would return: x since x occurs in every value of A. (1,2,3 and 4)
How can I get DISTINCT row COUNTs with different conditions in a single SELECT statement, and if count is zero get zero as a result?
I tried the following query:
I'm trying to insert data from one PostgreSQL 9.3 table to another while removing duplicate entries.
I have two tables containing email addresses.
The main table contains emails and a tag for each ...
I'm having issues using DISTINCT and COUNT in the same query. I would like to get unique items then get a total count for each month. (I've done this in two queries but I know there's a better way.)
I hope someone can teach me why MySQL is using temporary tables on a super simple select with a limit of 100 and how to get it do query more efficiently. I'm running MySQL 5.1.53-community.
I have a table sample
id | name | type
PR001 | DC001 | a
PR002 | DC001 | a
PR003 | DC001 | b
PR004 | DC002 | a
PR005 | DC003 | a
PR006 | DC003 ...
I have two tables, linked through Artists Firstnames and surnames. One table has the artists BIOG (only one result per Artist.), the other table has the Artist's images (a lot of images per artist).
I have a table with commercial agents and some invoices that they have manipulated.
I am searching the agents based on very simple conditions, such as whether the invoice identifiers are null or not.
I have two queries that appear to be logically equivalent, yet they return different result sets. I am using the AdventureWorks2012 database.
The first query uses an EXISTS clause with a sub query.
I have a one-to-many relationship between two tables, where I need to get distinct values out of a summed column b while limited by another summed field a
t1.a - sum(t2.a) as a,
t1.b - ...
I have alphanumeric values as my primary key. I am querying my database in two different ways and finding different results. It is almost certain that I might be missing some key point in my queries. ...