Solved

SELECT statement

Posted on 2011-09-26
19
207 Views
Last Modified: 2012-05-12
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
Comment
Question by:egovernment
  • 8
  • 5
  • 2
  • +2
19 Comments
 
LVL 61

Expert Comment

by:mbizup
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 33

Expert Comment

by:Norie
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

by:egovernment
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

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

Author Comment

by:egovernment
ID: 36598539
What are the fieldnames in your table?

Emp_Id
Emp_Name
From_Date
To_Date
Salary_Amount
0
 
LVL 61

Expert Comment

by:mbizup
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

by:
mbizup earned 500 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

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

what is your table representing?
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:egovernment
ID: 36983836
I will review the all answers
0
 
LVL 68

Expert Comment

by:Qlemo
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

by:egovernment
ID: 37197546
There no correct ansewr
0
 

Author Comment

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

There no correct answer
0
 

Author Comment

by:egovernment
ID: 37197551
There no correct answer
0
 
LVL 33

Expert Comment

by:Norie
ID: 37197563
There was no response from the questioner for 3 weeks.
0
 
LVL 61

Expert Comment

by:mbizup
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

by:egovernment
ID: 37209089
Thanks for all

I don't need the answer for this question
0
 

Author Comment

by:egovernment
ID: 37225049
Ok

The correct answer is mbizup
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now