this is the query how can i write a expression rule for this and the result will be like below
Discussion posts and replies are publicly visible
What's wrong with using QueryEntity or QueryRecordType (depending on which type of data you have configured within Appian)? These are both pretty powerful and you can filter to pretty much anything you want using a!queryFilter() or an array of filters contained in a!queryLogicalExpression().
As Mike Schmitt suggested use queryentity or queryrecordtype. Please go through https://docs.appian.com/suite/help/24.3/Query_Recipes.html if you are new to Appian to understand how this can be achieved.
KM
If your query is a simple select statement, you can directly query from db using QueryEntity or QueryRecordType. Within these you can modify data like applying filers.
In case of joins and unions, I would prefer to go with view in the backend and then query through QueryEntity or QueryRecordType.
Query Recipes - Appian 24.3
Accessing the data from the database can be achieved in two ways in your case:
1. Query entity : Appian's OOB functionality to query a data from the connected DB tables and views
2. Query Database Smart Service: used to retrieve information from an external database using a SQL query, and update or create process variables using the query results. This activity also permits you to create tables and select, insert, and update rows in database tables from your process model.
Please refer this link for more info
docs.appian.com/.../Query_Database_Smart_Service.html
You can use query entity function and provide the required filters using query filter. In case if you want to use joins, then you can use views on DB and use that view for query entity.