ferreira12 Posted August 8, 2013 at 02:28 PM Report #521227 Posted August 8, 2013 at 02:28 PM Olá Estou com o seguinte erro na minha query The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. no meu select tenho o campo imagem, como estou a fazer sum, ele obriga-me a colocar um group by, o problema é que quando coloco o campo image no group by dá me o erro acima descrito, já tentei converter, mas não resultou. Existe alguma possibilidade de contornar?
bruno1234 Posted August 8, 2013 at 06:33 PM Report #521262 Posted August 8, 2013 at 06:33 PM Como estás a fazer a query? De qualquer forma recomendo que não uitilizes o tipo image porque está deprecated. Utiliza antes varbinary(max). Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos
ferreira12 Posted August 9, 2013 at 09:48 AM Author Report #521317 Posted August 9, 2013 at 09:48 AM A query que estou a utilizar é: select top 40 ProdutosExist.ArtigoRef , Sum(Qtd1+Qtd2+Qtd3)AS Total, [fnVendas].qtd, Fotos.imagem from ProdutosExist inner join [dbo].[fnVendas]('08-08-2013 00:01','08-08-2013 23:59') on [fnVendas].ProdutosRef= ProdutosExist.ProdutosRef inner JOIN Fotos ON '0'+SUBSTRING([fnVendas].ProdutosRef,1,3)+SUBSTRING([fnVendas].ProdutosRef,5,4)+'.jpg' = ImagemN group by ProdutosExist.ProdutosRef, [fnVendas].qnt,[fnVendas].ProdutosRef, Fotos.Imagem order by [fnVendas].qnt desc
bruno1234 Posted August 9, 2013 at 06:25 PM Report #521379 Posted August 9, 2013 at 06:25 PM O melhor é deixares a foto de fora do group by e da query. Depois de teres os resultados agrupados, então sim, fazes um join para obter a foto. Precisas de carregar logo todas as imagens? Se só precisares delas depois, ganhas em performance se não as trouxeres, a dimensão ainda deve ser significativa para 40 fotos. Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos
ferreira12 Posted August 13, 2013 at 09:53 AM Author Report #521588 Posted August 13, 2013 at 09:53 AM Como é que faço o esse join?
ferreira12 Posted August 14, 2013 at 11:28 AM Author Report #521725 Posted August 14, 2013 at 11:28 AM utilizei Left join, mas a conclusao foi o mesmo erro.. ou seja voltei ao mesmo sitio. Quando falas em join e junção, qual é a tua ideia para agrupas as fotos?
ferreira12 Posted August 19, 2013 at 04:01 PM Author Report #522122 Posted August 19, 2013 at 04:01 PM Alguém me consegue ajudar?
xBoShY Posted August 27, 2013 at 03:04 PM Report #522754 Posted August 27, 2013 at 03:04 PM (edited) with totais as (select top 40 ProdutosExist.ArtigoRef, Sum(Qtd1+Qtd2+Qtd3) AS Total, fnVendas.qtd from ProdutosExist inner join dbo.fnVendas('08-08-2013 00:01','08-08-2013 23:59') on fnVendas.ProdutosRef = ProdutosExist.ProdutosRef group by ProdutosExist.ProdutosRef, fnVendas.qnt, fnVendas.ProdutosRef order by fnVendas.qnt desc) select totais.ArtigoRef, totais.Total, totais.qtd, Fotos.imagem from totais left join Fotos on '0'+SUBSTRING(totais.ProdutosRef, 1, 3)+SUBSTRING(totais.ProdutosRef, 5, 4)+'.jpg' = Fotos.ImagemN Edited August 27, 2013 at 03:07 PM by xBoShY
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now