MySQL Forums
Forum List  »  Optimizer & Parser

HELPPPPPPPPPPPPPPP PLEASE
Posted by: Odimar Tomazeli
Date: May 04, 2006 12:21PM

How can I do group comcept using only one table? I have this query

Select
cur_cce.BillDate,
cur_cce.Environment,
cur_cce.CompanyCode,
cur_cce.StateCode,
cur_cce.AltArCompanyCode,
cur_cce.BillingTelephoneNumber,
cur_cce.CustomerAccountNumber,
cur_cce.CustomerName,
cur_cce.CustomerBillingAddress,
cur_cce.TypeOfAccount,
cur_cce.CustomerTaxCode,
cur_cce.CurrentCharges,
cur_cce.GSTExempt,
cur_cce.OSTExempt,
cur_cce.QSTExempt,
cur_cce.GSTExemptAmount,
cur_cce.OSTExemptAmount,
cur_cce.QSTExemptAmount
From
cbss_customer_exempt cur_cce Left Join
cbss_customer_exempt prev_cce On cur_cce.Environment = prev_cce.Environment And cur_cce.CompanyCode = prev_cce.CompanyCode And cur_cce.StateCode = prev_cce.StateCode And cur_cce.AltArCompanyCode = prev_cce.AltArCompanyCode And cur_cce.BillingTelephoneNumber = prev_cce.BillingTelephoneNumber And cur_cce.CustomerAccountNumber = prev_cce.CustomerAccountNumber And cur_cce.CustomerName = prev_cce.CustomerName And cur_cce.CustomerBillingAddress = prev_cce.CustomerBillingAddress And cur_cce.TypeOfAccount = prev_cce.TypeOfAccount And cur_cce.CustomerTaxCode = prev_cce.CustomerTaxCode And prev_cce.BillDate Between '2006-12-01' And '2006-01-31'
Where
cur_cce.BillDate Between '2006-02-01' And '2006-02-28' And
prev_cce.BillDate Is Null

Here I have the same tabel cbss_customer_exempt and I have many records for each month, what I trying to do is comparing the records of two month using the same table to now what are the new records the are in this month and not in the last month and the records that are in the last month and are not in this month, I'm trying to get the data out side the intersection for both month in the same table.

I'm trying to get 1: Records that are only in current month and not in the previous month.
2: Records that are only in the previous month and not in the current month.

Thanks in advance.

Odimar



Edited 1 time(s). Last edit at 05/04/2006 12:23PM by Odimar Tomazeli.

Options: ReplyQuote


Subject
Views
Written By
Posted
HELPPPPPPPPPPPPPPP PLEASE
2813
May 04, 2006 12:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.