Find distinct from multiple columns [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 11 months ago.
Improve this question
I have 2 columns called price and PID in database called seatinginfo.
Both columns will have multiple of the same values like
pid 1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3
price 10,10,30,40,60,80,70,90,90,90,90 etc
I'm looking to make a query that will give me a list of all unique prices and pick just 1 or the max connected pid.
So example I only want one price,pid like 10,1 30,1 40,1 60,2 etc
Thanks

This is probably as simple as basic aggregation. Something like this should work based on the pretty vague details.
select price
, max(pid)
from YourTable
group by price

Related

How to pull list of all the customer with first_name as alphanumeric value [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 years ago.
Improve this question
I have a table name clients, now I want to pull a list of all the customers having first_name as alphanumeric value as an example, jriqbal23, sam45del etc.
If I need to pull the details of single customer, I can run below SQL:
select customer_id,email,first_name,last_name,middle_name from clients
where
email='jriqbal23#gmail.com';
how to change this query for pulling the list of all the customer having first name in similar way ?
thanks in advance.
If you use Oracle database, you can query client data with regexp_like:
Alphanumeric case:
select *
from clients
where regexp_like(first_name, '\w+');
Digits case:
select *
from clients
where regexp_like(first_name, '\d+');

POSTGRESQL: Insert Data from another table [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 years ago.
Improve this question
In above table customer ids are listed what I want to do is to get those ids from this table,
create another table named PROMOTION CLASSES where PREMIUM, PLUS AND NORMAL are in columns and put first 100 ids under PREMIUM COLUMN and soon.
Please help.
This creates you table with classification
CREATE TABLE promotion_classes as
SELECT customer_id,
case when customer_id < 100 then
'PREMIUM'
else
'NORMAL'
END as CLASSES
FROM CUSTOMER_TBL

Remove rows with duplicate value for a 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 4 years ago.
Improve this question
From the above table, I want to remove the rows that have the duplicate CODE column. Out of the duplicate rows, the row with the smallest ID_CHECK should be retained.
Output:
If I understand correctly, this should be your SQL query:
Select Names, Code, ID_CHECK
FROM
(
Select Names, Code, ID_CHECK,
ROW_NUMBER() OVER(Partition by Name,Code Order By ID_CHECK) as rnk
FROM table
)tmp
WHERE tmp.rnk=1;
Let me know if this works.

Write a query that select all events ordered by a particular customer in SQL [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 7 years ago.
Improve this question
In SQL how we will write a query that selects all events ordered by a particular customer. Kindly help me there.
Thanks
The table's name is events?...
Select * from events order by custumers asc
if not
select events from Table order by custumers asc

Problems with SQL query finding three names with the most records [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 a table and I want to display the 3 names (Ted, Ringo, Paul) that have the most records using an SQL query.
It's a primitive question, but please help me.
my table:
SELECT TOP 3 Name
FROM YourTable
GROUP BY Name
ORDER BY COUNT(*) DESC