Report Question

  • 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...

  • Have you tried a "group by"

  • Lookup aggregate functions in BOL.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • 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/

  • 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:

    NULL45

    AK4

    AL4

    AR2

    AZ16

    CA84

    CO16

    CT9

    DC4

    FL50

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply