![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I have a problem with one of my view. Basically, I need to create a view to sum the amount in Table A grouped by the EMPLOYEE_ID. But I also need the ability to limit the date range. [snip] This query will provide me what I need, but when I create the view over it, there is no way to pass in the date range I want. Any experts out there ? :-) I must accomplish this in a view. I would appreciate any advices anyone can give. |
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Arthur, Thanks for the suggestion. It worked out really great when I tried it in the SQL Editor. But for the time being, our users are running their reports though EXCEL ODBC. And they can't really execute any stored procedures or functions through it. All they can access is either user tables or views. So I must try to make this work via view for now. I will keep looking to see what I can do with what I have. I have been experimenting a lot with CTE (WITH Clause) or using GROUPING SETS without success. |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Hi, I have a problem with one of my view. Basically, I need to create a view to sum the amount in Table A grouped by the EMPLOYEE_ID. But I also need the ability to limit the date range. What I need to do is creating a view with the ability to limit the date range want the result sets to be broken down by employee_id (not dates). Is there an easy way to accomplish this ? Table_A ----------- ID EMPLOYEE_ID DATE AMOUNT 1 1 01/01/2006 100.00 2 1 01/02/2006 50.00 3 2 01/02/2006 25.00 4 1 01/03/2006 10.00 5 2 01/03/2006 15.00 6 3 01/03/2006 5.00 7 1 01/04/2006 10.00 8 2 01/04/2006 20.00 9 3 01/04/2006 30.00 --------------------------------------------------------------------- SELECT EMPLOYEE_ID,DATE,SUM(AMOUNT) FROM Table_A GROUP BY EMPLOYEE_ID,DATE ; -------------------------------------------------------------------- This query will give me the DATE column, so that I can pass in the date range I want in the view, but the result sets will also be broken down by employee and date. -------------------------------------------------------- SELECT EMPLOYEE,SUM(AMOUNT) FROM Table_A GROUP BY EMPLOYEE_ID; -------------------------------------------------------- This query will provide me what I need, but when I create the view over it, there is no way to pass in the date range I want. Any experts out there ? :-) I must accomplish this in a view. I would appreciate any advices anyone can give. Thanks What is wrong with: |
#8
| |||
| |||
|
|
Hi Dave, Thank you very much for all the info. Yes, I was referring to the MS Query. That's what our users have been running their EXCEL reports against. Something better should be coming along in the future, but I'm stuck with this for now. So I've kinda gotta work with what I was given :-) I don't have much knowledge on this VB stuff, but it does sound fantastic and flexible. Would you show me the rope ? Now I have more google search to do haha. |
#9
| |||
| |||
|
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |