473,394 Members | 1,946 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,394 software developers and data experts.

SQL 7: One column's value is repeated throughout entire result set

I'm using the following query to look in a log file and show some
statistics. It counts the total number of views and the total number
of unique users who have viewed a particular item (the "id" and
"title" fields are associated with the item).

SELECT title, COUNT(id) AS NumberViews, COUNT(DISTINCT UID) AS
NumberUniqueUsers, Type, id
FROM ActivityLog
WHERE dtTime >= 'Nov 1 2004 12:00AM' AND DtTime <= 'Nov 1 2005
12:00AM'
GROUP BY Title, Type, hdnId
ORDER BY TopViewed desc

This works fine on SQL Server 2000 (our development machine), but on
SQL Server 7 (our production machine), the title column has the same
value for every row. The other columns show the correct values.

If I remove the "ORDER BY" clause, then it works fine. If I remove
the "COUNT(DISTINCT UID)" column, it works fine. If I totally remove
the WHERE clause, it works fine.

Any ideas? It seems like a bug since it works fine on sql2k. I've
tried adding OPTION (MAXDOP 1) to the end of the query, but that
didn't help.

We're using SQL Server 7.0 sp1, and my boss doesn't want to risk
upgrading to sp4 because it might screw up all of our other
applications. I looked through all of the sp2 through sp4 bug fixes,
and I didn't see anything specifically mentioning this.

Thanks.
Jul 20 '05 #1
2 4239
Am I missing something, or do you not have the order by columns in the
result set?

"Caleb" <ca********@gmail.com> wrote in message
news:fd**************************@posting.google.c om...
I'm using the following query to look in a log file and show some
statistics. It counts the total number of views and the total number
of unique users who have viewed a particular item (the "id" and
"title" fields are associated with the item).

SELECT title, COUNT(id) AS NumberViews, COUNT(DISTINCT UID) AS
NumberUniqueUsers, Type, id
FROM ActivityLog
WHERE dtTime >= 'Nov 1 2004 12:00AM' AND DtTime <= 'Nov 1 2005
12:00AM'
GROUP BY Title, Type, hdnId
ORDER BY TopViewed desc

This works fine on SQL Server 2000 (our development machine), but on
SQL Server 7 (our production machine), the title column has the same
value for every row. The other columns show the correct values.

If I remove the "ORDER BY" clause, then it works fine. If I remove
the "COUNT(DISTINCT UID)" column, it works fine. If I totally remove
the WHERE clause, it works fine.

Any ideas? It seems like a bug since it works fine on sql2k. I've
tried adding OPTION (MAXDOP 1) to the end of the query, but that
didn't help.

We're using SQL Server 7.0 sp1, and my boss doesn't want to risk
upgrading to sp4 because it might screw up all of our other
applications. I looked through all of the sp2 through sp4 bug fixes,
and I didn't see anything specifically mentioning this.

Thanks.

Jul 20 '05 #2
Caleb (ca********@gmail.com) writes:
I'm using the following query to look in a log file and show some
statistics. It counts the total number of views and the total number
of unique users who have viewed a particular item (the "id" and
"title" fields are associated with the item).

SELECT title, COUNT(id) AS NumberViews, COUNT(DISTINCT UID) AS
NumberUniqueUsers, Type, id
FROM ActivityLog
WHERE dtTime >= 'Nov 1 2004 12:00AM' AND DtTime <= 'Nov 1 2005
12:00AM'
GROUP BY Title, Type, hdnId
ORDER BY TopViewed desc

This works fine on SQL Server 2000 (our development machine), but on
SQL Server 7 (our production machine), the title column has the same
value for every row. The other columns show the correct values.

If I remove the "ORDER BY" clause, then it works fine. If I remove
the "COUNT(DISTINCT UID)" column, it works fine. If I totally remove
the WHERE clause, it works fine.

Any ideas? It seems like a bug since it works fine on sql2k. I've
tried adding OPTION (MAXDOP 1) to the end of the query, but that
didn't help.

We're using SQL Server 7.0 sp1, and my boss doesn't want to risk
upgrading to sp4 because it might screw up all of our other
applications. I looked through all of the sp2 through sp4 bug fixes,
and I didn't see anything specifically mentioning this.


It certainly sounds like a bug to me. If you can produce a repro that
demonstrates the problem I can take a closer look.

How anyone could take responsibility to run SP1 of SQL7 is beyond me.
But unless it's possible to find a rewrite of the query that produces
the correct result, you will have to live with this, if you insist on
staying on SP1.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wayne Pierce | last post by:
I have a small script with PHP that queries a MySQL database to pull out one row, where I want to be able to access each of the columns separately. I have tried several different variations and am...
15
by: Garmt de Vries | last post by:
I would have guessed that this issue had been discussed to death, but I couldn't find an answer to my problem in the ciwas archives. So, at the risk of asking something trivial, here goes: I...
5
by: javaguy | last post by:
I have a data entry web application that is formatted heavily with tables. Having learned a bit of CSS, I'm hoping to rewrite this using <div> tags. But I have run into a formatting problem that...
11
by: Randell D. | last post by:
Folks, I have a table of addresses and a seperate table with contact names - All addresses tie to one or more names - I would like to keep track of the number of names 'belonging' to an address...
9
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval...
20
by: Steve Jorgensen | last post by:
Hi all, I've just finished almost all of what has turned out to be a real bear of a project. It has to import data from a monthly spreadsheet export from another program, and convert that into...
26
by: Martin R | last post by:
Hi, How to find first not null value in column whitout chacking whole table (if there is a not null value then show me it and stop searching, the table is quite big)? thx, Martin *** Sent...
4
by: Peter Gibbs | last post by:
I need some help with this problem. I'm using Access 2002 with XP. My problem is with a 2-column listbox. My VBA code puts text data into the listbox. The problem is that the text data...
3
by: Sheau Wei | last post by:
when the result print out , i want to make hyperlink for entire column of ID. what should i do?Below was my php code. //And we display the results while($result = mysql_fetch_array( $data )) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.