Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query Help

Author  Topic 

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2008-12-01 : 10:10:53
I am new to SQL and inherited this query and do not understand what it it trying to do. Can anyone help me with this?

select e.lastName, e.firstName, right(a.acctNumber, (len(a.acctNumber)
- charindex('.', a.acctNumber))) as Account_Number, h.daterequested, h.datefinalized,
h.requesterName, h.relationshipToMember,
h.reason, h.arrearsToForgive
from hardship_request h, account a, employee e where
h.account_id = a.id and a.id = e.account and
datediff(mm, h.dateFinalized, getdate()) = 1 and
status = 'Denied' ;

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-12-01 : 10:20:37
You are displaying employee details , account details and request details for all employees whose requests have been denied in the last 2 months.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-01 : 12:24:24
Last 2 months?

No... The previous month.
See here how DATEDIFF works http://www.sqlteam.com/article/datediff-function-demystified


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-12-02 : 06:27:10
quote:
Originally posted by Peso

Last 2 months?

No... The previous month.
See here how DATEDIFF works http://www.sqlteam.com/article/datediff-function-demystified


E 12°55'05.63"
N 56°04'39.26"




right, I'm sorry. Only the last month !
Go to Top of Page
   

- Advertisement -