Click here to Skip to main content
15,943,233 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All

Here my prob is how to use alias with this query....


Query:

SQL
SELECT convert(varchar(8), dateadd(second, SUM(DATEDIFF(SECOND, '00:00', LatenessN)), 0),  108) as Short from Daily where
EmpCodeC='003' and ClockDateD between ( '01/Jan/2015 12:00:00 AM') and ('31/Jan/2015 12:00:00 AM')


here i want to check Short <='02:00:00'

how to do this...
Posted

1 solution

SQL
Select * from 
(
SELECT convert(varchar(8), dateadd(second, SUM(DATEDIFF(SECOND, '00:00', LatenessN)), 0),  108) as Short from Daily where
EmpCodeC='003' and ClockDateD between ( '01/Jan/2015 12:00:00 AM') and ('31/Jan/2015 12:00:00 AM')
) T -- Not 'Table'
Where Short <='02:00:00'
 
Share this answer
 
v2
Comments
CHill60 22-Jan-15 6:42am    
Incorrect syntax near the keyword 'Table'.
This is because you have used the reserved word "Table" as the alias - change it to something else or (not advised) surround it with square brackets [Table]
Zoltán Zörgő 22-Jan-15 6:46am    
Table is a reserved word. You can use it but only like this:
) as [Table]
In this case it is easier to use an other alias for the subquery. Like t for example.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900