Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# SELECT statement

Posted on 2011-09-26
Medium Priority
258 Views
How in one select statement can display the employee get salaries in Augest and who the employee in that list take salary in the previous 3 month
0
Question by:egovernment
• 8
• 5
• 2
• +2

LVL 61

Expert Comment

ID: 36598357
Your question is a little hard to follow...

Can you post some sample data, and show what your expected results are?
0

LVL 36

Expert Comment

ID: 36598401
Do you mean employees who took a salary in August and also took a salary in the 3 months previous to that?

Which could meant took salary in May, June , July and August?
0

Author Comment

ID: 36598424
Do you mean employees who took a salary in August and also took a salary in the 3 months previous to that?

Yes
0

LVL 61

Expert Comment

ID: 36598508
What are the fieldnames in your table?
0

Author Comment

ID: 36598539
What are the fieldnames in your table?

Emp_Id
Emp_Name
From_Date
To_Date
Salary_Amount
0

LVL 61

Expert Comment

ID: 36598569
This might work for you:

SELECT * FROM YourTable
WHERE (Month(From_Date) + 3 >= Month(Now()) AND Year(From_Date) = Year(Now()))
OR (Month(To_Date) + 3 >= Month(Now()) AND Year(To_Date) = Year(Now()))
0

LVL 61

Accepted Solution

mbizup earned 2000 total points
ID: 36598681
Or this:

SELECT * FROM YourTable
WHERE Datediff("M", [From_Date],Now()) <= 3 OR Datediff("M", [To_Date],Now()) <= 3
0

LVL 50

Expert Comment

ID: 36598932
your request is ambiguous and requires clarification....

what do you mean by take salary?  (do you mean have been employed for at least 3 months ...?)

to answer you query requires either a Join or a subquery...

e.g.

select .... -- the information on employees "paid" in August
,(select 'Yes' .....
from someofyourtables as a where a.employeeid=x.employeeid
)  a subquery to answer the "take salary 3 months" question
from yourtable as x
where ....
0

Author Comment

ID: 36983836
I will review the all answers
0

LVL 72

Expert Comment

ID: 37197545
I've requested that this question be deleted for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Author Comment

ID: 37197546
There no correct ansewr
0

Author Comment

ID: 37225048
I've requested that this question be deleted for the following reason:

0

Author Comment

ID: 37197551
0

LVL 36

Expert Comment

ID: 37197563
There was no response from the questioner for 3 weeks.
0

LVL 61

Expert Comment

ID: 37200248
egovernment,

What were the actual results when you tried our suggestions, and how did they differ from what you needed?
0

Author Comment

ID: 37209089
Thanks for all

I don't need the answer for this question
0

Author Comment

ID: 37225049
Ok

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filledâ€¦
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give iâ€¦
###### Suggested Courses
Course of the Month10 days, 14 hours left to enroll