Unix Technical Forum

SQL Question - "Recursion"

This is a discussion on SQL Question - "Recursion" within the Pgsql General forums, part of the PostgreSQL category; --> Hi - Was wondering if anyone could help / had some thoughts. I am building a model for a ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-27-2008, 07:08 AM
ktr73
 
Posts: n/a
Default SQL Question - "Recursion"

Hi -

Was wondering if anyone could help / had some thoughts. I am building
a model for a client, and right now doing customer attrition
modeling. Basically, the number of customers in this period is equal
to:

Beg # Customers
+ customers added this period
- attrition
Ending # Customers

Obviously getting the beginning number of customers and # of added has
been easy via SQL. Also, the above is fairly straightforward in a
spreadsheet program like Excel. But I can't seem to come to grips
with how to model the attrition line item in SQL, as it's based on
last months ending balance ... which in turn is based on beg + add -
attr = end for the previous period, and so on.

So it seems to be a recursive function as far as I can tell ... any
idea how to model this via SQL? I can get running totals for the # of
adds with a correlated subquery, but I can't seem to figure out how to
build the attrition into that running total.

All help is greatly appreciated! Thanks,

Kevin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads for: SQL Question - "Recursion"

Thread Thread Starter Forum Replies Last Post
LOL! Errand Boy for "dickhitler" Espouses Intelligence???!!! PHC MISSION #6 "Destroy Netsys Mailing list" "Aliver" States He was Raped By Football Players!!! fuk@hushmail.com Bugtraq Full-disclosure 0 07-01-2008 09:27 PM
PhpNuke 7.8 with all security fixes/patches "Your_Account","Downloads", "Web Links" SQL Injection / Remote commans execution retrogod@aliceposta.it Bugtraq 0 07-01-2008 07:20 PM
For sell: SONY PLAYSTATION 3 60GB $300"""""""""60 GBUS VERSION Thompson Jackii OpenSolaris General 0 06-29-2008 12:15 PM
FATAL: no pg_hba.conf entry for host "???", user "rajaram", database "template1", SSL off Rajaram J pgsql Novice 2 04-17-2008 11:44 PM
ORA-04031: unable to allocate 2097152 bytes of shared memory ("shared pool","unknown object","hash-join subh","QERHJ Hash Table Entries") purohitatul@gmail.com Oracle Database 9 02-26-2008 08:41 AM


All times are GMT. The time now is 11:55 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com