You are on page 1of 3

Queries:

1. List CustomerID, FullName of customers who are female

SELECT CustomerID,fullname FROM bi.customermaster where sex='Female';

2.Count and display number of female customers

select count(*) from bi.customermaster where sex='Female';

3. Count and display number of male customers

select count(*) from bi.customermaster where sex='Male';

4. Count and list number of male and female customers

select count(if(sex='Female',1,null)) as Total_Females,


count(if(sex='Male',1,null)) as Total_Males
from bi.customermaster;

5. List the cities with the corresponding number of customers


select cityname,count(*) as customer from bi.customermaster group by cityname;

6. List cites in the descending order of number of customers

select cityname,count(*) as customer from bi.customermaster group by cityname order by customer


desc;

7. Identify top 10 high value customers

select customerid, sum(trnprice) as lts from orderitem oi

left join
ordertable od

using(orderno)

where trntype ='Sale' and customerid is not null and customerid !=0

group by customerid

order by lts desc

limit 10;

You might also like