How can I count the number of somethings in each column, and rename as something?
For example - this is my table:
PATIENT
PatientNum City
---------------------------
1 New York City
2 Boston
3 Birmingham
4 Tyler
5 Boston
6 New York City
This is my SQL query:
SELECT
City, COUNT(DISTINCT PatientNum) AS Freq
FROM
PATIENT
GROUP BY
City
Expected result
City Freq
----------------------
Birmingham 1
Boston 2
New York City 2
Tyler 1
What is the relational algebra for this SQL query? I am new to relational algebra, thank you for help!
Update:
I have do some research and write that. Is that right?