July 22, 2008 at 2:28 pm
Hey all,
Having an issue..
I have a table with a few thousand rows of data, one of those columns is "state" i am writing a report, what i'm trying to do is show each state as 1 line and then a total in the next row.
For some reason i cannot figure out why I cannot do this...
July 23, 2008 at 4:32 pm
Have you tried a "group by"
July 23, 2008 at 4:53 pm
Lookup aggregate functions in BOL.
Jeffrey Williams
Problems are opportunities brilliantly disguised as insurmountable obstacles.
How to post questions to get better answers faster
Managing Transaction Logs
July 27, 2008 at 1:23 am
Hope this will resolve your problem,
create table aaaa(id int,nam varchar(10),city varchar(10))
insert into aaaa values(1,'aa','sydney')
insert into aaaa values(2,'bb','delhi')
insert into aaaa values(3,'cc','chennai')
select * from aaaa
create table #temp1(id int, nam varchar(10))
insert into #temp1
select id,nam from aaaa
create table #temp2(id int, nam varchar(10))
insert into #temp2
select id,city from aaaa
select id,nam from #temp1 union all select * from #temp2
order by #temp1.id
Thanks and Regards,
Venkatesan Prabu, 😛
My Blog:
http://venkattechnicalblog.blogspot.com/
July 28, 2008 at 7:36 am
I have a table of names and addresses in our optout list. The fields are ID, Name, Address1, Address2, City, State, Zip. If you want to count the number of people by state do this:
select State, count(ID) as 'Number of people'
from dbo.DO_NOT_MAIL
group by State
order by State;
And you get something like this:
NULL 45
AK 4
AL 4
AR 2
AZ 16
CA 84
CO 16
CT 9
DC 4
FL 50
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply