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
Thales Junqueira
NA
5
551
How to do this query in LINQ
Aug 13 2018 8:20 AM
Hello everyone!
I having a problem with doing the query in LINQ. I use Firebird and my query is:
SELECT
(R.DATA_TERMINO + M.INTERVALO_MANUTENCAO_PREVENTIVA)
AS
PROXIMA_MANUTENCAO,
R.DATA_TERMINO,
M.STATUS
AS
SITUACAO,
R.NUMERO_RM,
M.MODELO,
M.FABRICANTE,
MT.CODMAT,
MT.DESCRICAO
AS
MATERIAL,
F.DESCRICAO
AS
FAMILIA_MATERIAL,
S.DESCRICAO
AS
SERVICO,
S.CODIGO_CENTRO_CUSTO,
FU.NOME
AS
REQUISITANTE,
CASE
R.POSICAO_SETOR_RESPONSAVEL
WHEN
0
THEN
'Em Manutenção'
WHEN
1
THEN
'Aguardando Peça'
WHEN
2
THEN
'Aguardando Avaliação'
WHEN
3
THEN
'Não Autorizada'
WHEN
4
THEN
'Concluída'
WHEN
5
THEN
'Aguardando Liberação do Setor Solicitante'
END
AS
POSICAO_RM
FROM
MANUFATURA M
LEFT
OUTER
JOIN
RM R
ON
M.ID_MATERIAL = R.ID_EQUIPAMENTO
LEFT
OUTER
JOIN
MATERIAL MT
ON
M.ID_MATERIAL = MT.CODIGO
LEFT
OUTER
JOIN
FAMILIA_MATERIAL F
ON
MT.CODIGO_FAMILIA_MATERIAL = F.CODIGO
LEFT
OUTER
JOIN
SERVICOS S
ON
M.ID_SETOR = S.CODIGO
LEFT
OUTER
JOIN
FUNCIONARIO FU
ON
R.ID_REQUISITANTE = FU.CODIGO
WHERE
M.intervalo_manutencao_preventiva > 0
AND
R.PERIODICA =
'S'
AND
r.id_setor_requisitado = 39
AND
R.DATA_INICIO =
(
SELECT
MAX
(xR.DATA_INICIO)
FROM
RM xR
WHERE
xR.ID_EQUIPAMENTO = M.ID_MATERIAL
AND
xR.TIPO = 2
AND
xR.PERIODICA =
'S'
)
AND
(
SELECT
FIRST
1 yR.SITUACAO
FROM
RM yR
WHERE
yR.ID_EQUIPAMENTO = M.ID_MATERIAL
ORDER
BY
yR.DATA_TERMINO
DESC
)
IN
(1,2,5)
ORDER
BY
S.DESCRICAO, 1
How can I do this? Mainly when comparing date fields within a subselect.
Tks.
Reply
Answers (
4
)
Evaluating the function
change database notification with using signalr linq