I have an Oracle database table with a field called Classification which is VARCHAR. The VARCHAR is a CSV(using semi colons). Example: I want to pull all the rows with ONLY a different value in the CSV from the others. It is ok if a row has a previously found value as long as it has a new different value.
Tag: distinct
count distinct if a condition is satisfied
I have a table which shows if a address_no has a telephone or not. To determine, i am looking at cell_phone and house_phone columns and want to write ‘no phone’ only when house_phone and cell_phone is …
How to count number of groups?
I have a table as follow: I want to count the number of distinct g_n. (Here it’s 3.) I have tried with: But it gives me the number of items per group. How can I count the number of distinct g_n? Answer Use count(distinct): There is no need to aggregate using group by for this result. Note: This ignores NULL
How to do I query all distinct rows with only their highest values?
I have been trying to query each city’s popular genre. I am only trying to get the rows that I have highlighted. I tried using MAX() on a group by but gave me a syntax error. My CTE query is as follows, its based on the dbeaver sample dataset: I tried the following query. Answer I don’t have a dataset
Incrementing / Decrementing data based on Running Distinct Count for Book lending scenario using Oracle SQL
I have a scenario which needs to be handled in Oracle SQL – that is a requirement. This is a book lending scenario which I am trying to create. Each student is entitled only so many number of books which is based on a credit system. In this sample Student ID ‘100’ is entitled for 4 books. Need to generate
MySQL query for multi-column distinct plus an ancillary column condition
Imagine a flat table that tracks game matches in which each game has three participants: an attacker, a defender and a bettor who is wagering on the outcome of the battle between players 1 and 2. The table includes the names of the players and the bettor of each game, as well as the date of the game, the scores
Can I Select DISTINCT on 2 columns and Sum grouped by 1 column in one query?
Is it possible to write one query, where I would group by 2 columns in a table to get the count of total members plus get a sum of one column in that same table, but grouped by one column? For example, the data looks like this I want to get a count on distinct combinations of columns “OHID” and
Grouping together results of multiple GROUP_CONCAT() with distinct values only
second attempt at this question with more detail. I am attempting to group the distinct values of multiple columns together for objects of the same name. I can use GROUP_CONCAT on each of the ‘Type’ columns, but I can’t merge them together to get a distinct set of values for each name Here is a sample of my data: And
How to do a SQL query with SRFs and display only distinct values?
I’m trying to think about a way to do a query with a single row function and display only distinct values. Lets suppose that I have a table employees with the columns employee, store and salary and I …
Select everything from SQL database except duplicate
I have a database that looks like this: It measures how many times participant1 and participant2 have shaked hands. I want to select the amount of times total people have shaken hands (without the duplicates counted). So in this example the output would be like this: Can anyone help me with the SQL Statement to do so? Answer With NOT