| | |
Oracle query help
Please support our Oracle advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Feb 2008
Posts: 6
Reputation:
Solved Threads: 0
I have to create a report based on the customer for particular order.
For example find all the customers who ordered an item ‘ABC’ for current month
and look back 11 months to find out if the same customers ordered the same item
and list all the customers who ordered ‘ABC’ in last 11 months
If 1000 customers ordered an item ‘ABC’ in June 09.
Check if any of the 1000 customers ordered ABC from July 08 to May 09.
If any list the customer.
Can you plz help me write the query for this? Thanks,
For example find all the customers who ordered an item ‘ABC’ for current month
and look back 11 months to find out if the same customers ordered the same item
and list all the customers who ordered ‘ABC’ in last 11 months
If 1000 customers ordered an item ‘ABC’ in June 09.
Check if any of the 1000 customers ordered ABC from July 08 to May 09.
If any list the customer.
Can you plz help me write the query for this? Thanks,
I think we would need a little more details to what you are asking.
Do you want a list of all customers that purchased a specific product in the current month only IF they had purchased the same product in the past 11 months?
The product will be a provided parameter?
It also sounds like this information would be held in multiple tables, are you not interested in how to pull these together; just how to make this comparison?
If you need to know how to join the tables a schema description of the tables would be required.
Do you want a list of all customers that purchased a specific product in the current month only IF they had purchased the same product in the past 11 months?
The product will be a provided parameter?
It also sounds like this information would be held in multiple tables, are you not interested in how to pull these together; just how to make this comparison?
If you need to know how to join the tables a schema description of the tables would be required.
Try something like this
This will only show a customer that has purchased a particular product in the current month as well as in the last 11 months.
sql Syntax (Toggle Plain Text)
SELECT customer FROM Table WHERE purchasedate BETWEEN trunc(SYSDATE,'MM') AND LAST_DAY (TO_DATE (trunc(SYSDATE,'MM'))) AND product = 'ABC' INTERSECT SELECT customer FROM table WHERE purchasedate BETWEEN add_months(trunc(SYSDATE,'MM'),-11) AND trunc(SYSDATE,'MM')-1 AND product = 'ABC'
This will only show a customer that has purchased a particular product in the current month as well as in the last 11 months.
Last edited by cgyrob; Jul 23rd, 2009 at 12:19 pm.
![]() |
Similar Threads
- How to match Todays date in sql (Java)
- looking for ASP.NET(C#,VB.NET) project work with SQL 2000 and 2005 (Post your Resume)
- Sum of field (Oracle)
- Crystal Report Err (Visual Basic 4 / 5 / 6)
- noob on perl... please help (Perl)
- index checking? (MySQL)
- Perl Script Help (Perl)
- perl script help re: scope/structure for noob (Perl)
Other Threads in the Oracle Forum
- Previous Thread: Create / Delete User account
- Next Thread: Why Oracle or other Databases?
Views: 514 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Oracle
2009predictions acquisition amazon.com bartz bernanke cia citrix cloudcomputing crm database dell economy editor enterprise enterprise2.0 enterprisesoftware erp federalreserve forbes hp ibm intellipedia internet larryellison layoffs linux loughridge mediawiki michaeljackson microsoft neverland nortel notebooks oil operatingsystem oracle palm rimm saas salesforce sap seagate socialcomputing sql sun sybase technologystocks virtualiron virtualization vmware wiki wikipedia xen yahoo zoho





