Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tabulate 1

Status
Not open for further replies.
Joined
Sep 12, 2007
Messages
45
Location
US

I am trying to create a query which will tabulate the following data:

Apt Number
101
203
402
501
504
202
105
1005
103
102
201
206
403
304
205
102
101
4066
3045
205
3001
205
503
5001
206
204

As..........
Apt. Numbers with | Totals
Apt. Numbers starting with number 1 | 7
Apt. Numbers starting with number 2 | 9
Apt. Numbers starting with number 3 | 3
Apt. Numbers starting with number 4 | 3
Apt. Numbers starting with number 5 | 4

I can do this for each criterion individually ............

select count(AptNmbr) as Totals
from Apartments
where AptNmbr like '1%';

But not in the tabulated form (created above manually) through a single query.


 
read the manuals - you need to look at group by and substring functions to accomplish this

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Got it!

select left(([Apt Number]),1) as 'Apt Number Starting with Number', count([Apt Number]) as GroupTotal
from Apartments
where [Apt Number] like '%'
group by left(([Apt Number]),1);

Thank you.
 
You don't need the WHERE clause in your query
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top