| hidden | true |
|---|
Let's say, we need to display order total amount on Customer table for each customer. All Orders we stored in the separate Orders table in the SQL database.
The resultCustomerstable contains: customer_id, photo, name, total_amountcolumns of data for each customer.
1. Go to the Component Settings then Add Data Resource
2. Select a resource (SQL database) then choose collection as Make an SQL request
Let's write a SQL query that returns customers includes the total amount column:
select
(select sum(amount) from orders where customer_id = customerscrm.id) as total_amount,
id,
photo,
name
from
customerscrmHere is a list of your available tables, you can see the table columns. You can use them while writing SQL, just click on the table name and the name will be automatically added.
Simply click Update Result button to run your SQL command.
Just close SQL Query Builder to start to customize the result table.
{% content-ref url="../../user-guide/data/make-a-sql-query.md" %} make-a-sql-query.md {% endcontent-ref %}





