How do I compare the values of records in the same table?

Asked 2 years ago, Updated 2 years ago, 28 views

There is a table called A.

If A has 10 data, compare these 10 data under certain conditions

조건에 맞는 데이터들만 뽑으려면 어떻게 해야하나요?

EX) Outputs a list of data of which the value of the column id is different among the records in Table

sql

2022-09-21 21:54

1 Answers

SELECT DISTINCT(column) FROM table

This ensures that the id value is printed without duplication.

Are you asking me this?

Or maybe you were asking this.

There's a column called pk (primary key) and a column called user_id on the table ABC, and if user_id wants to pull out anything that's different, you can do this.

select *
from (SELECT max(pk) as pk FROM ABC group by user_id) as A join ABC on A.pk = ABC.pk


2022-09-21 21:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.