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.
| Author |
Topic |
|
qwerty1234
Starting Member
13 Posts |
Posted - 2011-12-09 : 12:24:41
|
| Hello there, I have created a database for a DVD company. For a report section I have created a view which I plan to then bring up in the CMD window. What I am wanting to do is, provide an average of how many Rentals a Member has taken out, say in a month or a week whichever would be simpler. The problem I'm having is actually averaging this, I thought about averaging the number of dates but I'm having trouble implementing it. Any ideas? Here is my code so far:/*View*/CREATE VIEW testing ASSELECT M.memberID, R.rentalID, R.r_dateoutFROM testrental2 R LEFT JOIN testmember2 M /*Formatting and Computes etc*/SPOOL TEMPCLEAR COLUMNSCLEAR BREAKSCLEAR COMPUTESCOLUMN rentalID HEADING 'RENTAL ID'COLUMN memberID HEADING 'MEMBER ID'COLUMN r_dateout HEADING 'DATE OF RENTAL' BREAK ON rentalID SKIP 1 ON REPORTCOMPUTE COUNT OF memberID ON REPORTCOMPUTE COUNT OF rentalID ON REPORTSET PAGESIZE 24SET NEWPAGE 0SET LINESIZE 50TTITLE CENTER 'R E N T A L T R A C K E R' SKIP 2 -LEFT 'REPORT' RIGHT 'PAGE:' -FORMAT 999 SQL.PNO SKIP 2BTITLE CENTER 'FLIX CONFIDENTIAL'SELECT *FROM testing;SPOOL OFFDROP VIEW testing;Thank you in advance! |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-12-09 : 13:00:56
|
| Might try posting this on an Oracle forum, as this forum specialized on MS SQL Server. |
 |
|
|
|
|
|