Esta crónica fue aprobado por nuestros expertos así se garantiza la exactitud de nuestra esta noticia.
Solución:
Si está utilizando SQL Server 2012 o una versión superior, utilice “desplazar 0 filas” después de realizar el pedido. Ex –
create view Department_View
as
select Name from [HumanResources].[Department]
order by Name offset 0 rows
Como se indicó, ORDER BY no debe aparecer en las subconsultas a menos que se use TOP o FOR XML.
SELECT TOP 10 * FROM (
SELECT
c.id,
c.name,
c.inserteddate,
c.cityname,
ftblstates.name AS statename,
clc.name AS catname,
'' AS listingimagelogo,
'' AS orgname, relocateyn,
'' AS employerclassified
FROM tblclassifieds c
LEFT JOIN tblclassifiedscategories clc ON c.categoryid = clc.id
LEFT JOIN ftblstates ON c.stateid = ftblstates.id
WHERE c.expirydate != ''
AND NOT c.id IN (
SELECT TOP 10
tblclassifieds.id
FROM tblclassifieds
WHERE c.expirydate != ''
ORDER BY inserteddate desc
)
UNION ALL
SELECT
ce.id,
ce.name,
ce.inserteddate,
suburb AS cityname,
ftblstates.name AS statename,
ce.jobtype AS catname,
ce.listingimagelogo,
ce.orgname, '' AS relocateyn,
'1' AS employerclassified
FROM tblclassifiedemployers ce
LEFT JOIN ftblstates ON ce.stateid = ftblstates.id
WHERE ce.expirydate != ''
AND NOT ce.id IN (
SELECT TOP 10
tblclassifiedemployers.id
FROM tblclassifiedemployers
WHERE ce.expirydate != ''
ORDER BY inserteddate desc
)
) a ORDER BY inserteddate desc;
Valoraciones y reseñas
Agradecemos que desees añadir valor a nuestro contenido informacional colaborando tu experiencia en las explicaciones.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)