9900kf
9900kf

Reputation: 87

How to find change in column from table?

ID      PNUM    CUR    DTDATE    
---------------------------------------------
1       112233  001  31.01.2012
2       112233  001  31.03.2012
3       112233  001  30.04.2012
4       112233  058  31.05.2012
5       112244  001  31.01.2012
6       112244  398  31.03.2012

I have this table of records and I want to find out were there any change in column CUR for each PNUM throug all the time? How to write an SQL statements for this problem?

Upvotes: 0

Views: 51

Answers (1)

Prahalad Gaggar
Prahalad Gaggar

Reputation: 11609

Try the below Query. Also always mention the RDMS.

select PNUM,count(distinct CUR) changecount
from table
group by PNUM
having count(distinct CUR)>1

Upvotes: 2

Related Questions