SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Query


SQL Query

Author
Message
tn_350z
tn_350z
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 4
Hopefully, I am posting this in a right area if not I am sorry. Dont mind the $$$$,#### and ****

I am trying to get the last 60 days of records from today, and I am having issued writing the query that returns that value....RDMS its tie to SQL/Oracle database and here is my query that is currently working but I just like to see the last 60 days if anyone can possible help!!!


SELECT INFORMENT.PRODUCT_OFFER_PURCHASE.*******_#######, INFORMENT.INVOLVED_PARTY.INVOLVED_PARTY_ID, To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_ADDED, 'YYYYMMDD'), INFORMENT.DEPOSIT_$$$$$$$.BAL_LEDGER_CURRENT, INFORMENT.PRODUCT_OFFER_PURCHASE.INTEREST_RATE, To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_OPEN, 'YYYYMMDD'), To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_CLOSE, 'YYYYMMDD'), INFORMENT.PRODUCT_OFFER_PURCHASE.*******_STATUS_CODE, INFORMENT.PRODUCT_OFFER_PURCHASE.CLIENT_DEFINED
FROM INFORMENT.PRODUCT_OFFER_PURCHASE, INFORMENT.INVOLVED_PARTY, INFORMENT.DEPOSIT_$$$$$$$$$
WHERE INFORMENT.PRODUCT_OFFER_PURCHASE.INVOLVED_PARTY_ID_PRIMARY = INFORMENT.INVOLVED_PARTY.INVOLVED_PARTY_ID
AND INFORMENT.PRODUCT_OFFER_PURCHASE.******** = INFORMENT.INVOLVED_PARTY.*********
AND INFORMENT.PRODUCT_OFFER_PURCHASE.******** = INFORMENT.DEPOSIT_$$$$$$$.********
AND INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = INFORMENT.DEPOSIT_$$$$$$$.APPL_ID
AND INFORMENT.PRODUCT_OFFER_PURCHASE.*******_######## = INFORMENT.DEPOSIT_$$$$$$$$.******_#######
AND INFORMENT.PRODUCT_OFFER_PURCHASE.********* = '020'
and
(INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = 'SAV'
or
INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = 'DDA')
Sean Lange
Sean Lange
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63218 Visits: 17962
tn_350z (3/13/2013)
Hopefully, I am posting this in a right area if not I am sorry. Dont mind the $$$$,#### and ****

I am trying to get the last 60 days of records from today, and I am having issued writing the query that returns that value....RDMS its tie to SQL/Oracle database and here is my query that is currently working but I just like to see the last 60 days if anyone can possible help!!!


SELECT INFORMENT.PRODUCT_OFFER_PURCHASE.*******_#######, INFORMENT.INVOLVED_PARTY.INVOLVED_PARTY_ID, To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_ADDED, 'YYYYMMDD'), INFORMENT.DEPOSIT_$$$$$$$.BAL_LEDGER_CURRENT, INFORMENT.PRODUCT_OFFER_PURCHASE.INTEREST_RATE, To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_OPEN, 'YYYYMMDD'), To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_CLOSE, 'YYYYMMDD'), INFORMENT.PRODUCT_OFFER_PURCHASE.*******_STATUS_CODE, INFORMENT.PRODUCT_OFFER_PURCHASE.CLIENT_DEFINED
FROM INFORMENT.PRODUCT_OFFER_PURCHASE, INFORMENT.INVOLVED_PARTY, INFORMENT.DEPOSIT_$$$$$$$$$
WHERE INFORMENT.PRODUCT_OFFER_PURCHASE.INVOLVED_PARTY_ID_PRIMARY = INFORMENT.INVOLVED_PARTY.INVOLVED_PARTY_ID
AND INFORMENT.PRODUCT_OFFER_PURCHASE.******** = INFORMENT.INVOLVED_PARTY.*********
AND INFORMENT.PRODUCT_OFFER_PURCHASE.******** = INFORMENT.DEPOSIT_$$$$$$$.********
AND INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = INFORMENT.DEPOSIT_$$$$$$$.APPL_ID
AND INFORMENT.PRODUCT_OFFER_PURCHASE.*******_######## = INFORMENT.DEPOSIT_$$$$$$$$.******_#######
AND INFORMENT.PRODUCT_OFFER_PURCHASE.********* = '020'
and
(INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = 'SAV'
or
INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = 'DDA')


To see the last 60 days you need to determine which column(s) you can filter on. Then it is just Where [YourColumn] > dateadd(DAY, 60, getdate())

Also, you should use the newer join constructs and not the old style joins. Additionally table aliases would make far more legible.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)

Group: General Forum Members
Points: 95830 Visits: 38972
Sean Lange (3/13/2013)
tn_350z (3/13/2013)
Hopefully, I am posting this in a right area if not I am sorry. Dont mind the $$$$,#### and ****

I am trying to get the last 60 days of records from today, and I am having issued writing the query that returns that value....RDMS its tie to SQL/Oracle database and here is my query that is currently working but I just like to see the last 60 days if anyone can possible help!!!


SELECT INFORMENT.PRODUCT_OFFER_PURCHASE.*******_#######, INFORMENT.INVOLVED_PARTY.INVOLVED_PARTY_ID, To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_ADDED, 'YYYYMMDD'), INFORMENT.DEPOSIT_$$$$$$$.BAL_LEDGER_CURRENT, INFORMENT.PRODUCT_OFFER_PURCHASE.INTEREST_RATE, To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_OPEN, 'YYYYMMDD'), To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_CLOSE, 'YYYYMMDD'), INFORMENT.PRODUCT_OFFER_PURCHASE.*******_STATUS_CODE, INFORMENT.PRODUCT_OFFER_PURCHASE.CLIENT_DEFINED
FROM INFORMENT.PRODUCT_OFFER_PURCHASE, INFORMENT.INVOLVED_PARTY, INFORMENT.DEPOSIT_$$$$$$$$$
WHERE INFORMENT.PRODUCT_OFFER_PURCHASE.INVOLVED_PARTY_ID_PRIMARY = INFORMENT.INVOLVED_PARTY.INVOLVED_PARTY_ID
AND INFORMENT.PRODUCT_OFFER_PURCHASE.******** = INFORMENT.INVOLVED_PARTY.*********
AND INFORMENT.PRODUCT_OFFER_PURCHASE.******** = INFORMENT.DEPOSIT_$$$$$$$.********
AND INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = INFORMENT.DEPOSIT_$$$$$$$.APPL_ID
AND INFORMENT.PRODUCT_OFFER_PURCHASE.*******_######## = INFORMENT.DEPOSIT_$$$$$$$$.******_#######
AND INFORMENT.PRODUCT_OFFER_PURCHASE.********* = '020'
and
(INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = 'SAV'
or
INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = 'DDA')


To see the last 60 days you need to determine which column(s) you can filter on. Then it is just Where [YourColumn] > dateadd(DAY, 60, getdate())

Also, you should use the newer join constructs and not the old style joins. Additionally table aliases would make far more legible.


Shouldn't the dateadd look like this to go back 60 days, DATEADD(DAY, -60, GETDATE())?

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Sean Lange
Sean Lange
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63218 Visits: 17962
Lynn Pettis (3/13/2013)
Sean Lange (3/13/2013)
tn_350z (3/13/2013)
Hopefully, I am posting this in a right area if not I am sorry. Dont mind the $$$$,#### and ****

I am trying to get the last 60 days of records from today, and I am having issued writing the query that returns that value....RDMS its tie to SQL/Oracle database and here is my query that is currently working but I just like to see the last 60 days if anyone can possible help!!!


SELECT INFORMENT.PRODUCT_OFFER_PURCHASE.*******_#######, INFORMENT.INVOLVED_PARTY.INVOLVED_PARTY_ID, To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_ADDED, 'YYYYMMDD'), INFORMENT.DEPOSIT_$$$$$$$.BAL_LEDGER_CURRENT, INFORMENT.PRODUCT_OFFER_PURCHASE.INTEREST_RATE, To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_OPEN, 'YYYYMMDD'), To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_CLOSE, 'YYYYMMDD'), INFORMENT.PRODUCT_OFFER_PURCHASE.*******_STATUS_CODE, INFORMENT.PRODUCT_OFFER_PURCHASE.CLIENT_DEFINED
FROM INFORMENT.PRODUCT_OFFER_PURCHASE, INFORMENT.INVOLVED_PARTY, INFORMENT.DEPOSIT_$$$$$$$$$
WHERE INFORMENT.PRODUCT_OFFER_PURCHASE.INVOLVED_PARTY_ID_PRIMARY = INFORMENT.INVOLVED_PARTY.INVOLVED_PARTY_ID
AND INFORMENT.PRODUCT_OFFER_PURCHASE.******** = INFORMENT.INVOLVED_PARTY.*********
AND INFORMENT.PRODUCT_OFFER_PURCHASE.******** = INFORMENT.DEPOSIT_$$$$$$$.********
AND INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = INFORMENT.DEPOSIT_$$$$$$$.APPL_ID
AND INFORMENT.PRODUCT_OFFER_PURCHASE.*******_######## = INFORMENT.DEPOSIT_$$$$$$$$.******_#######
AND INFORMENT.PRODUCT_OFFER_PURCHASE.********* = '020'
and
(INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = 'SAV'
or
INFORMENT.PRODUCT_OFFER_PURCHASE.APPL_ID = 'DDA')


To see the last 60 days you need to determine which column(s) you can filter on. Then it is just Where [YourColumn] > dateadd(DAY, 60, getdate())

Also, you should use the newer join constructs and not the old style joins. Additionally table aliases would make far more legible.


Shouldn't the dateadd look like this to go back 60 days, DATEADD(DAY, -60, GETDATE())?


Doh. Thanks again for the correction Lynn.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search