Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
starsmile
Starting Member
2 Posts |
Posted - 2010-05-24 : 12:01:36
|
I have two tables and when i useselect b.BookID,b.BookName,b.Price,sum(Quantity) as SL from Books b join OrderDetails o on b.BookID = o.BookID group by b.BookID,b.BookName,b.Price order by SL descit works!but when i want to get BookContent of Book , i useselect b.BookID,b.BookName,b.Price,b.BookContent,sum(Quantity) as SL from Books b join OrderDetails o on b.BookID = o.BookID group by b.BookID,b.BookName,b.Price,b.BookContent order by SL descit shows errorThe text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.How can i get BookContent? I dont want to change type ntext of itThanks for replies |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-05-24 : 12:16:32
|
I can't see your pics coz its blocked within my n/w, but try converting to varchar(max) in the query aloneselect b.BookID,b.BookName,b.Price,convert(varchar(max),b.BookContent),sum(Quantity) as SL from Books b join OrderDetails o on b.BookID = o.BookID group by b.BookID,b.BookName,b.Price,convert(varchar(max),b.BookContent) order by SL desc |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-05-24 : 12:16:41
|
| What is the error?PBUH |
 |
|
|
starsmile
Starting Member
2 Posts |
Posted - 2010-05-24 : 13:04:20
|
| Oh thanks vijayisonly. I try your Query and it works. Thanks you very much! |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-05-24 : 13:15:10
|
| Np. You are welcome. |
 |
|
|
|
|
|
|
|