Hello friends, I have a table which contains more than 20 columns. Note: The structure of the table is incorrect as it was created a while ago and I cannot change it now. There are 2 specific columns in this table that currently concern me. You know the SQL question asking how many records are the same. This issue is similar, but it involves two columns. I need the code for this query - I can't figure it out. The snippet above shows a portion of the shareholders table. The problem lies in these two columns: sirano and okumaevi. The query output should have been like this, but I couldn't achieve it: The Foundation Board has 3 records. However, these three records should be grouped as follows: Okumaevi and Sirano should be in one group; the number of groups should be counted. It's difficult to explain. Let me provide more details, it will be lengthy but the important thing is to make it understandable. Grouping is involved here due to the database being very old and having many errors. If you pay attention, you'll see that Siranos form groups among themselves; when you look at consecutive rows, the sirano value continues consistently, and whenever it changes, the okumaevi column changes as well. This should be counted as 1; Below, there are okumaevi values for Vak?f Heyeti but with different sirano values, so this should be counted as +1, making a total of 2. For example, when I write this code: SELECT okumaevi, COUNT(*) AS count FROM shareholders GROUP BY okumaevi, sirano, the result is as follows. However, this is not the desired outcome - what is needed is to list how many records for each specific value such as how many for Ayazma and how many for Ba?larçe?me. For instance, there are 4 records for Ayazma.