Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

sum of the event Expand / Collapse
Author
Message
Posted Tuesday, October 14, 2008 2:23 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, November 25, 2009 4:57 PM
Points: 74, Visits: 550

Hi Every body

Could you please help me

Which channels watched most of the time any help me how can write a qurey for this


stat_id event_no channel event_tim
001 Pwr_on Etv 07:10:21 CDT06/13/1997
002 Dtv_ch Gemini 07:10:29 CDT06/13/1997
003 dtv_guide Etv 07:10:38 CDT06/13/1997

Post #585782
Posted Tuesday, October 14, 2008 2:41 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 8:26 AM
Points: 10,381, Visits: 13,436
What is the data type of the event_tim column? Do I need to find the time difference between row 1 and row 2 in order to get the time a channel was watched? So etv would be watched for 8 seconds and then Gemini for 9 seconds then back to etv, but there is on way of knowing when the last row ended in the data you supplied. What would I do with the last row?



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #585803
Posted Tuesday, October 14, 2008 2:48 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, November 25, 2009 4:57 PM
Points: 74, Visits: 550
hi friend


thank u for ur reply
that data type is 'evet_date'
now could u please give good suggestion how can i calulate the sum of them

Post #585811
Posted Tuesday, October 14, 2008 2:59 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 8:26 AM
Points: 10,381, Visits: 13,436
There is no such thing as an evet_date date type in SQL Server. It could be a user defined type and then you need to let me know what type it is based on.

I am assuming the data in that column means that event 1 took place on June 13, 1997 at 7:10:21 am. Is that a correct assumption?




Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #585825
Posted Tuesday, October 14, 2008 3:20 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, November 25, 2009 4:57 PM
Points: 74, Visits: 550
hi hall

'19:12:43 CDT 05/23/2007' this is event_date but it is in varchar datatype.

How can we convert varchar datatype to date time datatype any body plz give suggestion
Post #585836
Posted Tuesday, October 14, 2008 3:24 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 8:26 AM
Points: 10,381, Visits: 13,436
What does the CDT stand for? Are there other values besides CDT in the middle of the time and date?



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #585839
Posted Tuesday, October 14, 2008 3:38 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:51 PM
Points: 7,179, Visits: 15,772
kumar99ms (10/14/2008)
hi hall

'19:12:43 CDT 05/23/2007' this is event_date but it is in varchar datatype.

How can we convert varchar datatype to date time datatype any body plz give suggestion


You should look at converting these into UTC time, or something based off of a standard time zone. I'm assuming that CDT is Central Daylight time.

If you were to convert this to UTC time - you'd want to combine the date and time, then cast that as a datetime:
declare @ts varchar(40)

set @ts='19:12:43 CDT 05/23/2007'

select cast(right(@ts,10)+' '+left(@ts, 8) as datetime)


and then adjust by 5 hours (to get to UTC). Final code would look like:

declare @ts varchar(40)

set @ts='19:12:43 CDT 05/23/2007'

select dateadd(hour,5,cast(right(@ts,10)+' '+left(@ts, 8) as datetime))





----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #585845
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse