473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Need Help - Multiple Column in Group By clause with Data Type Error

This is the table structure I'm trying to query:

Storename varchar 50
Bussinessdate datetime 8
txnnumber text 16
subtotal float 8
discounts float 8
paidamount float 8
transactiontype text 16
time datetime 8

This is my query which results to " The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator."

select Storename, sum(Subtotal - Discounts) as gross,
Transactiontype, datepart(weekday, Time) as DWeekday,
datepart(hour, Time) as DHour, count(txnnumber) as tcount
from tMas_TxnSummary
where Bussinessdate >= '01/01/2008' and Bussinessdate <= '01/31/2008'
and Storename = 'Sample'
group by Storename,Transactiontype, datepart(hour, Time),datepart(weekday, Time);
Feb 5 '09 #1
4 3070
ck9663
2,878 Expert 2GB
Try changing the data type of Transactiontype column.

-- CK
Feb 5 '09 #2
I'm sorry I can't do that. It is an established database already and I'm not allowed to change anything, only to query. How else can I accomplish a result set like this?

BussinessDate Storename Transaction Type Dayoftheweek Hour Tcount Gross
Feb 5 '09 #3
ck9663
2,878 Expert 2GB
Try converting it to NVARCHAR.

-- CK
Feb 5 '09 #4
Thanks a lot it worked when i converted transactiontype to NVARCHAR. I tried also to do the same for the txnnumber field but COUNT applied to that converted field gives me an error, or does not work. What is the correct syntax to perform COUNT on a converted field?
Feb 6 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Shino | last post by:
Hi, Can anyone help with this error: "ORA-00904: invalid column name"? Thanks! SQL> create view PPFa as 2 SELECT L.UserID AS LecID, U.Name, U.Email, I.IntakeID, S.UserID AS StudID 3 FROM...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
5
by: malcolm | last post by:
Example, suppose you have these 2 tables (NOTE: My example is totally different, but I'm simply trying to setup the a simpler version, so excuse the bad design; not the point here) CarsSold {...
1
by: mlrehberg | last post by:
Hi, New to writing sql script I get this error in my sql script Server: Msg 512, Level 16, State 1, Line 1 Subquery returned more than 1 value. This is not permitted when the subquery...
2
by: JJA | last post by:
Please advise on how to get the GROUP BY coded in an acceptable way: DECLARE @LO INT DECLARE @HI INT DECLARE @StartDate varchar(10) DECLARE @EndDate varchar(10) SELECT @StartDate =...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
14
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity....
7
by: Andrew Tatum | last post by:
Alright, so I have this problem. I want to make it easy for me and others to be able to run a query and easily choose whether we want Merchants or NonMerchants. Previously, we would have to comment...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.