Groupin a view by DATE and TIME


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Groupin a view by DATE and TIME

  1. #1
    Peter Mardyrosian Guest

    Groupin a view by DATE and TIME


    Hi!

    I have a problem.

    I have a table with this information


    Data Date/Time
    D600 2000-02-10 07:00:30
    D600 2000-02-10 07:12:30
    W100 2000-02-10 07:10:00


    I want to count the number of occurences of D600 and W100 when i search for
    a specific time period. So that i will get this answer

    D600 2
    W100 1


    But when i try to do it i get this

    D600 1
    D600 1
    w100 1

    Is it possible in some way to get it in the way i want.

    I dont want to make a temporary view that show me

    D600 1
    D600 1
    W100 1

    and then make another view to on this. Because the application I am making
    is going to be used by several users.


  2. #2
    Dave F Guest

    Re: Groupin a view by DATE and TIME


    This'll work (there's probably a nicer way but...)
    select distinct(data),
    (select count(distinct datetime) from table b where b.data = a.data)
    from table a


    "Peter Mardyrosian" <pm_75@hotmail.com> wrote:
    >
    >Hi!
    >
    >I have a problem.
    >
    >I have a table with this information
    >
    >
    >Data Date/Time
    >D600 2000-02-10 07:00:30
    >D600 2000-02-10 07:12:30
    >W100 2000-02-10 07:10:00
    >
    >
    >I want to count the number of occurences of D600 and W100 when i search

    for
    >a specific time period. So that i will get this answer
    >
    >D600 2
    >W100 1
    >
    >
    >But when i try to do it i get this
    >
    >D600 1
    >D600 1
    >w100 1
    >
    >Is it possible in some way to get it in the way i want.
    >
    >I dont want to make a temporary view that show me
    >
    >D600 1
    >D600 1
    >W100 1
    >
    >and then make another view to on this. Because the application I am making
    >is going to be used by several users.
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center