rjoseph
11-06-2007, 09:58 AM
Hi guys
Basically, my database table ("vehicles") contains 5 fields. I have shown an example of what type of data is recorded within these fields below:
MAKE MODEL YEAR PRICE AREA
aston martin 2001 45000 London
aston martin 2002 47000 Manchester
aston martin 2002 50000 Birmingham
porsche 911 1999 32000 Liverpool
porsche 911 2002 38000 Liverpool
porsche 911 2005 43000 Manchester
Basically, I want to create an SQL statement which queries my table and displays the total number of cars there are in certain areas.
Thus, if I want to know how many cars there are in the areas of; London, Manchester, Birmingham, Liverpool, Leeds and Leicester, my page would look something like this:
----------------------
Cars in London: 1
Cars in Manchester: 2
Cars in Birmingham: 1
Cars in Liverpool: 2
Cars in Leeds: 0
Cars in Leicester: 0
----------------------
The "Cars in London: etc etc" text would be hardcoded into my page and so the number "1" would be what the sql query populates.
Has anyone got an ideas how I what my sql statement/query would look like and how I would achieve this?
Any help would be fully appreciated
I look forward to hearing from you
Rod from the UK
Basically, my database table ("vehicles") contains 5 fields. I have shown an example of what type of data is recorded within these fields below:
MAKE MODEL YEAR PRICE AREA
aston martin 2001 45000 London
aston martin 2002 47000 Manchester
aston martin 2002 50000 Birmingham
porsche 911 1999 32000 Liverpool
porsche 911 2002 38000 Liverpool
porsche 911 2005 43000 Manchester
Basically, I want to create an SQL statement which queries my table and displays the total number of cars there are in certain areas.
Thus, if I want to know how many cars there are in the areas of; London, Manchester, Birmingham, Liverpool, Leeds and Leicester, my page would look something like this:
----------------------
Cars in London: 1
Cars in Manchester: 2
Cars in Birmingham: 1
Cars in Liverpool: 2
Cars in Leeds: 0
Cars in Leicester: 0
----------------------
The "Cars in London: etc etc" text would be hardcoded into my page and so the number "1" would be what the sql query populates.
Has anyone got an ideas how I what my sql statement/query would look like and how I would achieve this?
Any help would be fully appreciated
I look forward to hearing from you
Rod from the UK