January 23, 2016 at 4:18 am
Hi, i need help please,
Why this not work:
SELECT change_dtim,create_dtim,ckpt_id,Format([change_dtim]-[create_dtim],'hh:nn:ss') as tempo FROM Back_ickpt_plz where tempo > '00:15:00'
if i remove the where tempo > '00:15:00' , run .
What is my mistake?
Thks a lot,
Regards,
Cachado
January 23, 2016 at 4:30 am
jcachado (1/23/2016)
Hi, i need help please,
Why this not work:
SELECT change_dtim,create_dtim,ckpt_id,Format([change_dtim]-[create_dtim],'hh:nn:ss') as tempo FROM Back_ickpt_plz where tempo > '00:15:00'
if i remove the where tempo > '00:15:00' , run .
What is my mistake?
Thks a lot,
Regards,
Cachado
Quick suggestion
😎
SELECT change_dtim,create_dtim,ckpt_id,[change_dtim]-[create_dtim] FROM Back_ickpt_plz where change_dtim > CONVERT(TIME,'00:15:00',0)
January 23, 2016 at 4:35 am
But i need bigger than 15 minutes!
The statement is ok but the condition > '00:15:00' dont work.
🙁
Thks,
Cachado
January 23, 2016 at 4:43 am
It won't run, because you're referencing an alias in the WHERE clause. Aliases only get assigned at a point after the WHERE has run.
You could do
SELECT change_dtim,create_dtim,ckpt_id,Format([change_dtim]-[create_dtim],'hh:nn:ss') as tempo FROM Back_ickpt_plz where Format([change_dtim]-[create_dtim],'hh:nn:ss') > '00:15:00'
It should work, won't be very efficient. To suggest a more efficient form, we're going to need to see the data types and sample data for the table.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 23, 2016 at 4:55 am
jcachado (1/23/2016)
But i need bigger than 15 minutes!The statement is ok but the condition > '00:15:00' dont work.
🙁
Thks,
Cachado
You have 15 minutes passed midnight in your query, if you need anything different then you must ask for that otherwise you will not get what you need.
😎
January 23, 2016 at 4:56 am
Please see the file:
https://www.dropbox.com/s/3ok41iuqg9pqd2p/1.png?dl=0
i need only the records in expression > 15 minutes
🙁
Regards,
Cachado
January 23, 2016 at 5:00 am
Eirikur Eiriksson (1/23/2016)
jcachado (1/23/2016)
But i need bigger than 15 minutes!The statement is ok but the condition > '00:15:00' dont work.
🙁
Thks,
Cachado
You have 15 minutes passed midnight in your query, if you need anything different then you must ask for that otherwise you will not get what you need.
😎
But the field have the difference in minutes between the change_dtim field and the field create_dtim!!
January 23, 2016 at 5:22 am
GilaMonster (1/23/2016)
It won't run, because you're referencing an alias in the WHERE clause. Aliases only get assigned at a point after the WHERE has run.You could do
SELECT change_dtim,create_dtim,ckpt_id,Format([change_dtim]-[create_dtim],'hh:nn:ss') as tempo FROM Back_ickpt_plz where Format([change_dtim]-[create_dtim],'hh:nn:ss') > '00:15:00'
It should work, won't be very efficient. To suggest a more efficient form, we're going to need to see the data types and sample data for the table.
Thks its work but change the > with >
Regards,
Cachado
January 23, 2016 at 5:38 am
Strongly advice you not to use the format function as it performs very badly.
😎
January 23, 2016 at 6:22 am
Eirikur Eiriksson (1/23/2016)
Strongly advice you not to use the format function as it performs very badly.😎
What your sugestion to replacing format command?
Thks,
JC
January 23, 2016 at 3:08 pm
jcachado (1/23/2016)
Eirikur Eiriksson (1/23/2016)
Strongly advice you not to use the format function as it performs very badly.😎
What your sugestion to replacing format command?
Thks,
JC
Like Gail said, we need to see the DDL for the table to be able to suggest an efficient approach. See the link in my signature for descriptions of DDL, sample data and expected output. This sounds pretty simple, but without knowing the table you're querying, there's really no way to offer any suggestions.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply