Solved

SELECT statement

Posted on 2011-09-26
19
217 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run Time Error 3075 15 44
Cross Tab with two column values 7 32
From msAccess  SaveAs an excel file SILENTLY without opening excel 4 29
SQL Query Syntax Join 4 32
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

911 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

24 Experts available now in Live!

Get 1:1 Help Now