how can I get the row of value that also occurred in other row?

Barry

As a beginner to sql, I have a table like below in PostgreSQL.

id  product type  occured_at                  
 1        A    6  2017-03-17 10:21:22.935278
 1        B    6  2017-04-17 10:21:22.941801
 1        B    8  2017-04-17 10:21:22.935278 
 1        B    8  2017-05-17 10:21:22.935278
 1        D    8  2017-06-17 10:21:22.935278
 2        C    4  2017-04-24 10:21:22.938517   
 3        A    8  2017-04-27 10:21:22.941801  
 4        C    8  2017-09-17 10:21:22.941801  
 4        C    6  2017-09-17 10:21:22.941801
 5        D    8  2017-09-17 10:21:22.941801

The question is how can I get the id and product which has different types that occurred on the same date. Just like

id  product     
 1        B
 4        C

If anyone can help me out, I really appreciate it :)

Aaron Dietz

A self join is one approach:

SELECT DISTINCT A.ID, A.Product
FROM YourTable A
JOIN YourTable B ON A.ID = B.ID
                AND A.Product = B.Product
                AND DATE(A.Occured_at) = DATE(B.Occured_at)
                AND A.Type <> B.Type

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get all row value of datgrid in flex when i click on any row and compare with other datagrid

From Dev

How can I get the selected row's value of a qtablewidget in PyQt?

From Dev

How i can get value of specific cell if row is checked?

From Dev

How to add row and column value as a tag of UIButton so that i can get row and column value on button click?

From Dev

How to add row and column value as a tag of UIButton so that i can get row and column value on button click?

From Dev

How can i select every other row?

From Dev

How to get the first row corresponding cell value if i change the other rows cell value in kendo child grid

From Dev

How can I add a value to a row in pyspark?

From Dev

How can i get gridview row count

From Dev

How can I get the "row" from indexPathsForSelectedRows?

From Dev

MySQL can you use LIMIT to return n rows, but then also return any other row whose value matches the nth row?

From Dev

How to get value of a <td> onclick to an other <td> of a same row?

From Dev

How can I spilt a row data in to below other rows

From Dev

How can I get a percentile value for each dataframe row considering a subset of the data?

From Dev

How can I get row value for each sap.m.select element

From Dev

how can i get a gridview column number from the header row value

From Dev

How can I get row value for each sap.m.select element

From Dev

How Can I get the value in the gridview footer row of textbox and dropdownlist in asp.net c# webform

From Dev

How can I get the corresponding user_id (auto increment) value of a particular row in my database?

From Dev

How to increment so can I get the next column value not the new row in list view?

From Dev

How can get value "Id" row in DataGrid using event MouseDoubleClick?

From Dev

How to get the value of the row in DataTables

From Dev

How can I retrieve a row by index value from a Pandas DataFrame?

From Dev

How can I SELECT the first row with MAX(Column value)?

From Dev

How can I set data-row value in javascript

From Dev

In PostgreSQL how can I return the entire row that corresponds with the min of a value?

From Dev

How can i create a "twin" of a row and update just one value

From Dev

How can I set data-row value in javascript

From Dev

How can I reference a row in another sheet based on value in cell?

Related Related

  1. 1

    How to get all row value of datgrid in flex when i click on any row and compare with other datagrid

  2. 2

    How can I get the selected row's value of a qtablewidget in PyQt?

  3. 3

    How i can get value of specific cell if row is checked?

  4. 4

    How to add row and column value as a tag of UIButton so that i can get row and column value on button click?

  5. 5

    How to add row and column value as a tag of UIButton so that i can get row and column value on button click?

  6. 6

    How can i select every other row?

  7. 7

    How to get the first row corresponding cell value if i change the other rows cell value in kendo child grid

  8. 8

    How can I add a value to a row in pyspark?

  9. 9

    How can i get gridview row count

  10. 10

    How can I get the "row" from indexPathsForSelectedRows?

  11. 11

    MySQL can you use LIMIT to return n rows, but then also return any other row whose value matches the nth row?

  12. 12

    How to get value of a <td> onclick to an other <td> of a same row?

  13. 13

    How can I spilt a row data in to below other rows

  14. 14

    How can I get a percentile value for each dataframe row considering a subset of the data?

  15. 15

    How can I get row value for each sap.m.select element

  16. 16

    how can i get a gridview column number from the header row value

  17. 17

    How can I get row value for each sap.m.select element

  18. 18

    How Can I get the value in the gridview footer row of textbox and dropdownlist in asp.net c# webform

  19. 19

    How can I get the corresponding user_id (auto increment) value of a particular row in my database?

  20. 20

    How to increment so can I get the next column value not the new row in list view?

  21. 21

    How can get value "Id" row in DataGrid using event MouseDoubleClick?

  22. 22

    How to get the value of the row in DataTables

  23. 23

    How can I retrieve a row by index value from a Pandas DataFrame?

  24. 24

    How can I SELECT the first row with MAX(Column value)?

  25. 25

    How can I set data-row value in javascript

  26. 26

    In PostgreSQL how can I return the entire row that corresponds with the min of a value?

  27. 27

    How can i create a "twin" of a row and update just one value

  28. 28

    How can I set data-row value in javascript

  29. 29

    How can I reference a row in another sheet based on value in cell?

HotTag

Archive