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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Where Clause with a View using Group by

Author  Topic 

jrosser
Starting Member

14 Posts

Posted - 2009-02-19 : 09:10:12
I am creating an ASP.net app and I am trying to speed it up by doing the grouping in the server.

Example:
Create view Branch_Sales as
Select branch_id,sum(sales),sum(cost)
from sales_cube
group by branch_id

So if someone wanted to see sales by branch I would use this view, the problem is if I want to pass a Where Clause such as invoice_date. Invoice_date is a field in Sales_Cube but it is not in the View I created, so I get an error that invoice_date does not exist. I am wondering if there is some type of work around for this.

Thank you
Jeremy

X002548
Not Just a Number

15586 Posts

Posted - 2009-02-19 : 09:23:20
no

Wouldn't there be many invoice dates?

Which one would you want? All of them?

If so, we could probably do that with a join between the view and your "cube" based on branch_id





Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

jrosser
Starting Member

14 Posts

Posted - 2009-02-19 : 09:33:05
I would have 2 text boxes where the user can set any date range, so I would need all dates. I guess doing a join is the only way to do that.

I will give that a try.

Jeremy
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-19 : 10:05:56
quote:
Originally posted by jrosser

I am creating an ASP.net app and I am trying to speed it up by doing the grouping in the server.

Example:
Create view Branch_Sales as
Select branch_id,sum(sales),sum(cost)
from sales_cube
group by branch_id

So if someone wanted to see sales by branch I would use this view, the problem is if I want to pass a Where Clause such as invoice_date. Invoice_date is a field in Sales_Cube but it is not in the View I created, so I get an error that invoice_date does not exist. I am wondering if there is some type of work around for this.

Thank you
Jeremy


if date filed is not in cube, you need to add it to view and then use it in where condition.
Go to Top of Page
   

- Advertisement -