Simple Count logic

Results 1 to 2 of 2

Thread: Simple Count logic

  1. #1
    Join Date
    Dec 1969

    Default Simple Count logic

    I have a access 2k table with a field "LINE1" which contains an int from 0 up. I simply want a count of every instances of any int. Then display it and insert it into a form. I have a sql statment as such but i am not getting what i need out of it.<BR><BR>select LINE1, count(*)<BR>from MS_Access_Floating_Adress<BR>group by LINE1 <BR>order by LINE1<BR><BR>I get each instance but where do i get the count #??<BR>

  2. #2
    Join Date
    Dec 1969

    Default Logic is fine... if you want to be able to get the count *by name* you need to give it a name:<BR><BR>SELECT LINE1, COUNT(*) AS LineCount FROM ...<BR><BR>But it has been working all along. You just needed to do:<BR><BR>&#060;%<BR>SQL = "SELECT LINE1, COUNT(*) FROM ..."<BR>Set RS = yourConnection.Execute( SQL )<BR>Do Until RS.EOF<BR> line1val = RS(0) &#039; *or* RS("LINE1")<BR> line1count = RS(1)<BR> ...<BR> RS.MoveNext<BR>Loop<BR>%&#062;<BR><BR>If you don&#039;t use AS to give an alias to an aggregate or other calculated field, you can still get its value *by position*. But you can use AS to assign an alias name, too.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts