SQL how to find number of unique id's [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
enter image description here
enter image description here
Hi, I was wondering how I will find the number of unique (different) customers found in the list above. I have shown the code I have written up but not sure how to get unique Customer ID count as you can see there are many duplicate customerID's because each customer can match with many products.

You can use count(distinct):
select count(distinct customer_id)
from t;

Related

How can I limit some specific numbers and return them with a title? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 days ago.
Improve this question
I have a table in postgresql which contains scores of students and I wanna show scores less than 10 with word 'failed' and more than 10 with the word 'passed'. How can I do that using a query?
As result I want a table with two columns. First scores and second 'passed' or 'failed'.

Is there a faster way to add new column data with hundreds of rows? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
I have a decent-sized table 'countries' with about 10 columns. I recently added a new column to the table 'GDP' and I am entering the information per row using
UPDATE countries
SET GDP=(value)
WHERE name = (country);
I have 200 countries in this table. Is there a better way to update this information?
This project is from Khan Academy. We are asked to select a database and run queries on it. The data was pulled from https://gist.github.com/pamelafox/ad4f6abbaac0a48aa781
I am just making sure that there isn't a more efficient way of adding this information to the existing table 'countries' where the primary key is the name of the country.

Count without duplicates [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I'd like to count column values without any duplicates.
In the given example, I'd expect the SQL query to sum up column a to 6 (every value counted once)
How about
select count(distinct a)
from table

In Oracle SQL, how do I find where a column may be referenced using just queries? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a specific column, called DELIVER_TO_LOCATION_ID , which is in a table called apps.po_requisition_lines_all
I need to dig into the database and derive the continent from the DELIVER_TO_LOCATION_ID ,
In SQL Developer I can't seem to find a way to do this .
any tips appreciated. thanks
You can use following command-
desc tableName
It'll give you description of table including every column in it having any constraints on it or not like primary key, reference key etc.

like query for searching a multiple word in table column in sql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have table named 'categories' and it has one column name 'catvalues' with values see example below:
catvalues
------------------------
Party wear,Plain,Classic
Party wear,Plain
Party wear,Classic
now i want like query which when i search for 'Party wear,Classic' it should return 2 rows like below:
catvalues
---------------------------
Party wear,Plain,Classic
Party wear,Classic
maybe something like...
SELECT * FROM table
WHERE catvalues LIKE '%Party wear%Classic%'
but i really need more info about your questions
This sounds like your trying to put to much information into one column.