Reputation: 191
this is my query:
SELECT location_description as Crimes,COUNT(*)
FROM test_sample
where test_sample.day_of_week LIKE"%sunday"
GROUP BY test_sample.location_description
UNION ALL
SELECT location_description as Crimes,COUNT(*)
FROM test_sample
where test_sample.day_of_week LIKE"%saturday"
GROUP BY test_sample.location_description
How can i merge this two duplicate values into one.
Upvotes: 0
Views: 45
Reputation: 6456
If you need get count of records only by 'location_description' field than you can use only grouping without union
SELECT location_description AS Crimes,
COUNT(*)
FROM test_sample
WHERE day_of_week LIKE "%sunday"
OR day_of_week LIKE "%saturday"
GROUP BY location_description
Upvotes: 3
Reputation: 44716
No need to UNION
now, simply adjust WHERE
to include both days;
SELECT location_description as Crimes,COUNT(*)
FROM test_sample
where test_sample.day_of_week LIKE"%sunday"
or test_sample.day_of_week LIKE"%saturday"
GROUP BY test_sample.location_description
Upvotes: 3