What is relational database and why not use Excel?
- SQL is used everywhere.
- It’s in high demand because so many companies use it.
- Although there are alternatives, SQL is not going anywhere.
Tables we use
- leads
- sales
- dify
- documents
select WHAT from TABLE ADDITIONAL OPTIONS
Can you find the latest sale number in sales table?
select lead_no, first_name, last_name
from leads
Can you select sale_no and estimated_annual_saving from sales table?
select sale_no, estimated_annual_saving
from sales
select * from leads
where opener_user_name = "RumerAllner"
Can you select sales for closer MatthewGallafant?
select * from sales
where closer = "MatthewGallafant"
select * from leads where is_allocated = 1
Can you select all sales with bill? (has_bill)
select * from sales where has_bill = 1
select * from leads
where created_at > "2019-01-01"
Can you select all sales created in this zone?
select * from sales
where created_at > "2019-08-01"
select * from leads
where opener_user_name != "RumerAllner"
Can you select sales excluding sales closed by agent MattBarratt?
select * from sales
where closer != "MattBarratt"
select * from leads
where opener_user_name = "RumerAllner"
and created_at > "2019-01-01"
Can you select sales created in this zone and closed by MattBarratt?
select * from sales
where closer = "MattBarratt"
and created_at > "2019-08-01"
select * from leads
where opener_user_name = "RumerAllner"
or opener_user_name = "mattbarratt"
Can you select sales closed by JusticePene or MattBarratt in this zone?
select * from sales
where (closer = "JusticePene"
or closer = "mattbarratt")
and created_at > "2019-08-01"
select count(*) from leads
where lead_source = "MIC Form Fill"
Can you find count of all sales in this zone?
select count(*) from sales
where created_at > "2019-08-01"
select sum(live_revenue) from sales
where created_at > "2019-08-01"
Can you find sum of estimated_annual_saving from sales in this zone?
select sum(estimated_annual_saving)
from sales
where created_at > "2019-08-01"
select sum(live_revenue), closer
from sales
where sales_stage = 'Closed Won'
and reconciliation_stage IN ('Live')
group by closer
order by sum(live_revenue) DESC
Can you find sum of estimated_annual_saving group by closer from sales in this zone? Who is our leader?
select sum(estimated_annual_saving), closer
from sales
where sales_stage = 'Closed Won'
and reconciliation_stage IN ('Live')
group by closer
order by sum(live_revenue) DESC