0

Hello i have some table like this:

Text | from | to    
A    | 1    | 2     
B    | 2    | 1     
C    | 3    | 1 
D    | 1    | 4

And i would like to get number of conversations, so for this example it should be 3. Do anyone know how to do it? Thank you.

One more information - i decided to use UUID so i switched to PostgreSQL and there is no least and greatest.

Jack
  • 93
  • 11
  • 2
    One way is with LEAST and GREATEST. It's a no-brainer, so I'll leave you to figure out the details. – Strawberry Aug 09 '17 at 09:26
  • From your data, it looks "conversations" refers to "from" column. In that case, if you use, select count(1) from group by from will do it. Provide your requirements correctly to get quick answer
    – priya raj Aug 09 '17 at 09:27
  • @priyaraj Plainly, `conversations` refers to both the `from` and the `to` column. – Strawberry Aug 09 '17 at 09:31
  • Well with least and greatest will be problem because my example is not the same as real data. Real IDS are UUID. – Jack Aug 10 '17 at 09:21

1 Answers1

0

SELECT * FROM your_table_name name_of_you_like_to_select WHERE name_of_you_like_to_select.from = 3; You can use some SQL query like this.

  • This doesn't answer the question as the asker wishes to know how many distinct pairings there are, ignoring which column order they come in. – Jonathan Twite Aug 09 '17 at 09:46