How to count the data from table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fary4u
    Contributor
    • Jul 2007
    • 273

    #1

    How to count the data from table

    Hi

    how to count the data ( not count the record )from the table & with the following id ?

    i'm using asp classic with ado MS Access database
    with simple query
    "select * from order where orderid = 1"
    Code:
    orderID | Prod ID | Qnty
    1  |  3  |  2
    1  |  2  |  1
    2  |  2  |  1
    2  |  4  |  1
    for example result like this i.e ------------------
    Code:
    orderID | Qnty
    1  |  3
    
    you got 3 record
  • viktorka
    New Member
    • Jun 2010
    • 26

    #2
    Select count(*) from order where orderid = 1

    Comment

    • Fary4u
      Contributor
      • Jul 2007
      • 273

      #3
      Originally posted by viktorka
      Select count(*) from order where orderid = 1
      SELECT count(Qnty) As Count from order WHERE orderid = 1

      Comment

      • viktorka
        New Member
        • Jun 2010
        • 26

        #4
        I would not recommend using Count as a name of as column. SQL may not generate an error, however, later you may get confused where is a function call and where a column name. In this case you have to use it in the brackets
        SELECT count(Qnty) As [Count] from order WHERE orderid = 1

        Comment

        • Fary4u
          Contributor
          • Jul 2007
          • 273

          #5
          Originally posted by viktorka
          I would not recommend using Count as a name of as column. SQL may not generate an error, however, later you may get confused where is a function call and where a column name. In this case you have to use it in the brackets
          SELECT count(Qnty) As [Count] from order WHERE orderid = 1
          Hi viktorka

          thanks for reply actually this query work fine me
          SELECT count(Qnty) As [Count] from order WHERE orderid = 1

          i though i'll share with you :)

          coz i'm particular looking count the Qnty this is why i just draw my table structure

          thanks anyway for you help :)

          Comment

          Working...