Avatar of JameMeck
JameMeckFlag for United States of America

asked on 

MS SQL count total time.

I have a database like the excel file below, I want to count total time which value < 400, please help me this problem, thanks!
Time(varchar)
Value: int

Time      Value
3:39:35      429
3:39:40      433
3:39:45      438
3:39:50      443
3:39:55      399
3:40:00      300
3:40:05      453
3:40:10      455
3:40:15      457
3:40:20      398
3:40:25      460
3:40:30      460

--> like the data above, total time < 400 is:  (3:40:05 - 3:39:50) + (3:40:25 - 3:40:15)
Microsoft SQL Server 2005Microsoft SQL Server 2008

Avatar of undefined
Last Comment
JameMeck
Avatar of PazHRC
PazHRC

you have to do a cast on the query or a better query:

SELECT CAST('00:00:00' AS time), CAST('10:00' AS datetime)
and you form your query

or

SELECT * FROM table.time
WHERE Time1<= '00:00:00'

have a nice day
i hope this can help you

SOLUTION
Avatar of CapitanHarlock
CapitanHarlock
Flag of Spain image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
why are you doing that?

 (3:40:05 - 3:39:50) + (3:40:25 - 3:40:15)
ASKER CERTIFIED SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of JameMeck
JameMeck
Flag of United States of America image

ASKER

Thank you so much! I got it.
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo