COUNT
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: COUNT

  1. #1
    Join Date
    May 2002
    Posts
    232
    Hiiii,I want to display total count of rows at webinter face.
    My question is,
    I have 5 columns in my table
    1)Advid ------primary key
    2)advtisetype---------------we can enter "wanted or forsale"
    3)newentries------anynew entry.
    4)advdate------ is advtisementdate
    5)userid------foreign key column from other table

    In my webportal i need to display total newentries weekly count only,but in case of advtisementtype ,i like to display total count of forsale and wanted.
    In my portal output like--

    FORSALE 30 ---(TOTALCOUNT)
    WANTED 50 --(TOTALCOUNT)
    NEWENTRIES 5 ---- (TOTALCOUNT WEEKLONLY)
    I am not geting mixed query of out put as shown above.
    thanks
    kavitha

    kavitha
    Share on Google+

  2. #2
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    Code:
    SELECT advtisetype, COUNT(*)
    FROM mytable
    WHERE advdate BETWEEN date1 AND date2
    GROUP BY advtisetype
    UNION
    SELECT 'NEWENTRIES' , COUNT(*)
    FROM mytable
    WHERE advdate BETWEEN date1 AND date2
    and newentries IS NOT NULL;
    Assuming that newentries column is NULL if its not a new entry. Or if it is a flag then change the where condition.

    Sanjay
    Share on Google+

  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    kavithared you dont have to duplicate your efforst in two forums

    closing
    Share on Google+

Posting Permissions

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


Click Here to Expand Forum to Full Width