Click here to Skip to main content
16,009,144 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
Use Shoppingkart
select P.ProductSNo,
P.ProductName,
P.ProductDescription,
P.ProductPrice,
P.ProductImage,
P.CategorySNo,
P.CategorySNo,
P.ProductQuantity,
C.CategoryName,
Isnull(Sum(CP.TotalProducts),0) as ProductSold

From Products P
Inner Join Category C
On P.CategorySNo=C.CategorySNo

LEFT Join CustomerProducts CP
On P.ProductSNo=CP.ProductSNo

Group BY
P.ProductSNo,
P.ProductName,
P.ProductDescription,
P.ProductPrice,
P.ProductImage,
P.CategorySNo,

P.ProductQuantity,
C.CategoryName


I got This error::

The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
Posted
Updated 17-Sep-15 22:10pm
v2

1 solution

As the error says, some of the data types aren't comparable. In your statement I'd guess it's P.ProductImage.

One option is that you first select the 'normal' data and then use that result set and combine it with the image data. In other words, something like

SQL
select a.*,
       (select p.productimage 
        from product p
        where p.productsno = a.productsno) AS ProductImage
from (
      select P.ProductSNo,
      P.ProductName,
      P.ProductDescription,
      P.ProductPrice,
      P.CategorySNo,
      P.CategorySNo,
      P.ProductQuantity,
      C.CategoryName,
      Isnull(Sum(CP.TotalProducts),0) as ProductSold
      From Products P
      Inner Join Category C
      On P.CategorySNo=C.CategorySNo
      LEFT Join CustomerProducts CP
      On P.ProductSNo=CP.ProductSNo
      Group BY
      P.ProductSNo,
      P.ProductName,
      P.ProductDescription,
      P.ProductPrice,
      P.CategorySNo,
      P.ProductQuantity,
      C.CategoryName) a

The joining column may be incorrect in the example, but you know the structure of the database better :)
 
Share this answer
 
v3
Comments
Member 11804811 19-Sep-15 2:20am    
Thankyou....It Works For me...
Wendelius 19-Sep-15 3:35am    
You're welcome. Glad it helped :)
Kashif Ali 29-Mar-21 8:38am    
Thank You This is Working Perfect

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