Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 5th, 2006, 12:39 AM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Assistance with Rollup and Cube

My assignment question is (using the Pubs database):
Create another query but instead of the compute use the Rollup, and then use the CUBE. How are these different from the COMPUTE? Explain your answer.

What I have done is:
SELECT type, AVG (price)
FROM titles
GROUP BY type WITH ROLLUP

SELECT type, AVG (price)
FROM titles
GROUP BY type WITH CUBE

I donít think I did this correctly tho because my results didnít appear to change.

Did I use the Rollup and/or Cube incorrectly?


Reply With Quote
  #2 (permalink)  
Old November 5th, 2006, 04:37 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 Posts
Default

Hi Jinn,

Take a look at SQL Server's Books Online. There's lots of information about ROLLUP and CUBE in the index under "CUBE operator" and "ROLLUP operator".

The examples in these topics should be enough to explain the difference and help you out.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old November 5th, 2006, 09:18 AM
Friend of Wrox
Points: 1,533, Level: 15
Points: 1,533, Level: 15 Points: 1,533, Level: 15 Points: 1,533, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
Posts: 474
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Quote:
quote:Originally posted by Jinn
 My assignment question is (using the Pubs database):
Create another query but instead of the compute use the Rollup, and then use the CUBE.††How are these different from the COMPUTE?††Explain your answer.

What I have done is:
SELECT type, AVG (price)
FROM titles
GROUP BY type WITH ROLLUP

SELECT type, AVG (price)
FROM titles
GROUP BY type WITH CUBE

I donít think I did this correctly tho because my results didnít appear to change.

Did I use the Rollup and/or Cube incorrectly?
With only a single column in a GROUP BY, Rollup and Cube will show the same thing... try these queries, instead...

SELECT City,State,COUNT(*)
FROM STORES
GROUP BY City,State WITH ROLLUP

SELECT City,State,COUNT(*)
FROM STORES
GROUP BY City,State WITH CUBE

--Jeff Moden
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Select errors on Count() w/ rollup for a datagrid cJeffreywang ASP.NET 2.0 Basics 0 April 7th, 2008 07:14 PM
how to add perspectives in a Cube through C# mayafantasy ADO.NET 0 February 14th, 2007 08:33 AM
Rollup Question kjward SQL Server 2000 0 February 7th, 2007 10:51 AM
Accessing cube in VB ashwinik VB Components 1 January 25th, 2005 05:09 AM



All times are GMT -4. The time now is 07:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.