0

I have this posgresql query

SELECT 
ss.id ss_number
,(SELECT create_date FROM sales_sourcing_chat WHERE chat_id = ss.id ORDER BY create_date DESC LIMIT 1) create_date_update
FROM sales_sourcing ss
WHERE ss.state NOT IN ('draft','cancel')
    AND ss.source_type = 'import'
ORDER BY create_date_update DESC

and the result :

id | create_date_update
aa | 
bb |
cc | 2023-02-01 06:58:39.437057
dd | 2023-01-31 06:27:44.442038

The result that I want is:

id | create_date_update
cc | 2023-02-01 06:58:39.437057
dd | 2023-01-31 06:27:44.442038
aa | 
bb |

Thank you for the help.

Nur Faiz
  • 59
  • 4

0 Answers0