473,732 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PL/SQL -- 12-month range window count

6 New Member
Heya

I've got a table of invoices, which have dates and customer_id's. What I need to get is the number of occurances for this customer for a 12-month range window. For example, if there's an invoice for october for a certain customer - i want to count how many other invoices appear are for this customer in the 12 months from that invoice date. Similarly, if there's an invoice in november, that should show the number of occurences 12 months from this november date too.

Also one further element is to only count 1 occurence by month-week. So if there are 3 occurences of a customer in the same week of month, it is counted as 1. I believe you can do something like this with a
Expand|Select|Wrap|Line Numbers
  1. count(distinct customer_id ||'~'|| trunc(invoice_date, 'IW')
-- to get the unique international week.

I think i need something like..
Expand|Select|Wrap|Line Numbers
  1. count ( distinct customer_id||'~'||trunc(invoice_date, 'IW') ) over (order by invoice_date asc range 100 preceding) customer_count1
But you're not allowed to but 'distinct' in there apparently.

Any suggestions? Any ideas are appreciated.

Thanks
Jul 19 '07 #1
0 2866

Sign in to post your reply or Sign up for a free account.

Similar topics

52
5880
by: Dick Moores | last post by:
I need to figure out how to compute pi to base 12, to as many digits as possible. I found this reference, <http://mathworld.wolfram.com/Base.html>, but I really don't understand it well enough. Could someone show me how to do what I need? Thanks, Dick Moores rdm@rcblue.com
2
2971
by: Martijn Rutte | last post by:
Hi, On one side, I have a Sybase 12.5 32 bits Server running on AIX 5.1 (maintenance level 3). On the other, I've got W2000 5.00.2195 (SP2) with SQL Server Standard Edition, Product Version 8.00.534 (SP2), having installed MDAC 2.6. I connect to the Sybase 12.5 database using Merant ASE ODBC driver for Sybase 12.5, and using the Microsoft OLE DB Provider for SQL Server that comes with this SQLServer version.
2
1221
by: Brett | last post by:
Let's say some one makes the argument that instead of multi threading an application, they say it's better just to make multiple applications. The app does the same thing for different modules. The modules are conceptually the same. They contain mostly data but some processing to get data. The app knows nothing about how they get the data. Just that they return data in a starndard format. The argument is based on 12 apps vs. 1 multi...
0
1560
by: dicky2283 | last post by:
windows development community please help me im deepak roy , doing my final year undergrad in computer science.... im doing a project - Motion detection and Tracking in vc++( video for windows). The project combines image acquisition, manipulation techniques with other image processing techniques and neural network approaches. im using video for windows to capture images from a webcam( EZONICS CAM II ). if u have used video for windows,...
1
1144
by: Jason Shohet | last post by:
Someone in my group created an aspx with 12 tables on it, each with several rows in the table. In codebehind, we often make 1 or more tables visible / invisible. (However within each table, there is no need to make individual rows visible / invisible). I always believed that tables are much more overhead than just having 1 table with lots of rows (Is that true?). So, I suggested, "Just have 1 table, and the <tr> 's we'll make...
11
2534
by: vips | last post by:
I have a string str="10*12*14" now I want the total of this value i.e. 10 multiply 12 multiply 14 how do i get it ? is there any function in vb.net to do that ?? if i put it as query to database I get the result, but I want to do it in the code.
1
1050
by: David Lozzi | last post by:
Howdy, Below is my SELECT statement. The returned list is suppose to return the TOP 12 when sorted by MIN(dtDate). It sorts the records correctly and only displays 12 records, but to meet the 12 record criteria, it removes a record that should be #6. If I change the 12 to a 13, that missing record appears, however now its 13 and not 12. The UNION is to add a blank record at the end so i can capture the last record in my DataList to...
4
2148
by: Sharon | last post by:
I'm using an xml schema (XSD) that has a point data in it, so when I'm saving the schema (from memory with values) to an XML file, the point value is saved in the form of: "{X=12, Y=34}" And that is very good. Also when I'm loading the XML file with the schema to a DataSet, this "{X=12, Y=34}" is converted nicely to a point. I wish to do this same conversion from "{X=12, Y=34}" string pattern to a point in memory (without XML schema),...
0
1944
by: Ranger | last post by:
TRANSFORME R$12,00 EM R$12.000,00 SÓ VAI TOMAR UM POUCO DO SEU TEMPO E VC Ñ VAI SE ARREPENDER ACREDITE!!! LEIA COM ATENÇÃO. MÉTODO APROVADO PELA REVISTA EXAME Você já imaginou ganhar até R$ 12.000,00 ou mais, em pouco tempo? Acha impossível? Leia este artigo e comemore!!! Eu encontrei esta mensagem em um site e decidi tentar. Pouco curioso por natureza, continuei lendo. Logo abaixo, o texto apresenta uma
0
2501
by: Ranger | last post by:
TRANSFORME R$12,00 EM R$12.000,00 SÓ VAI TOMAR UM POUCO DO SEU TEMPO E VC Ñ VAI SE ARREPENDER, ACREDITE!!! MÉTODO APROVADO PELA REVISTA EXAME Você já imaginou ganhar até R$ 12.000,00 ou mais, em pouco tempo? Acha impossível? Leia este artigo e comemore!!! Eu encontrei esta mensagem em um site e decidi tentar. Pouco curioso por natureza, continuei lendo. Logo abaixo, o texto apresenta uma
0
9447
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.