TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Goran Bibic
478
2.9k
200.2k
Sql group and multiple oredr by...
May 3 2018 3:11 PM
Like this...
error is Msg 156, Level 15, State 1, Line 13
Incorrect syntax near the keyword 'group'.
SELECT a.radnik, isnull(convert(varchar(20), a.vrijemeodjave, 113),
''
) as vrijemeodjave, convert(varchar(20), b.vrijemeprijave, 113) as vrijemeprijave,
--CASE WHEN DATEPART(WEEKDAY, b.vrijemeprijave) in (1,7) then 0
else
(CASE WHEN (DATEDIFF(SECOND, b.vrijemeprijave, a.vrijemeodjave) / 3600) > 8 THEN 8 ELSE(DATEDIFF(SECOND, b.vrijemeprijave, a.vrijemeodjave) / 3600) END) end AS radni_sati,
--CASE WHEN DATEPART(WEEKDAY, a.vrijemeodjave) in (1,7) then (DATEDIFF(SECOND, b.vrijemeprijave, a.vrijemeodjave) / 3600)
else
(
case
when(DATEDIFF(SECOND, b.vrijemeprijave, a.vrijemeodjave) / 3600) > 8 then ((DATEDIFF(SECOND, b.vrijemeprijave, a.vrijemeodjave) / 3600)-8) ELSE NULL END) end AS prekovremeni
SUM(cast((CASE WHEN DATEPART(WEEKDAY, 01) in (1, 7) then 0
else
(CASE WHEN(DATEDIFF(SECOND, 01, 3) / 3600) > 8 THEN 8 ELSE(DATEDIFF(SECOND, 01, 3) / 3600) END) end)as
float
)) AS ukupno_radni_sati,
SUM(cast((CASE WHEN DATEPART(WEEKDAY, 3) in (1, 7) then(DATEDIFF(SECOND, 01, 3) / 3600)
else
(
case
when(DATEDIFF(SECOND, 01, 3) / 3600) > 8 then((DATEDIFF(SECOND, 01, 3) / 3600) - 8) ELSE NULL END) end)as
float
)) AS
'Ukupno rekovremeni'
FROM(SELECT radnik, vrijemeodjave, ROW_Number() OVER(Partition By IdPrijava ORDER BY vrijemeprijave) as RowNum
FROM dbo.prijava_radnika) a INNER JOIN(SELECT radnik, vrijemeprijave, (ROW_Number() OVER(Partition By IdPrijava ORDER BY vrijemeprijave) - 1) as RowNumMinusOne FROM dbo.prijava_radnika)
group by a.radnik
Reply
Answers (
2
)
Duplicate records in my table
How to Generate Script From Database with Where Clause