Repository navigation
Expand file tree
/
Copy pathcomplaints.sql
More file actions
51 lines (35 loc) · 1.72 KB
/
Copy pathcomplaints.sql
File metadata and controls
51 lines (35 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--Dataset of Consumer Complaints
Select *
From ConsumerComplaints;
--Dataset was extracted from Excel file in CSV format
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- 1. Find out how many complaints were received and sent on the same day
Select COUNT(*) as "Complaints dealt on the same day"
From ConsumerComplaints
Where DATEDIFF(day,Date_Received, Date_Sent_To_Company) =0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--2. Extract the complaints received in the states of New York
Select COUNT(*) As "Complaints from New York"
From ConsumerComplaints
Where State_Name = 'NY';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--3. Extract the complaints received in the states of New York and Carlifornia
Select COUNT(*) As "Complaints from New York and Carlifonia"
From ConsumerComplaints
Where State_Name = 'CA'or State_Name = 'NY';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--4. Extract all rows with the word 'Credit' in the Product field
Select Date_Received,Product_Name
From ConsumerComplaints
Where Product_Name LIKE '%Credit%';
Select COUNT(*) AS "Rows with the word credit"
From ConsumerComplaints
Where Product_Name LIKE '%Credit%';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--5. Extract all rows with the word "Late" in the issue field
Select Date_Received, Product_Name, Issue, Company,State_Name
From ConsumerComplaints
Where Issue LIKE '%Late%';
Select COUNT(*) AS "Consumers complaining about late fee "
From ConsumerComplaints
Where Issue LIKE '%Late%';