-
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.
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks