to give if condition in MS Access

P

pol

Please let me know to give if condition in MSAccess

For example I have a table SALES with following structure

salesamt
docdate

want to select 'SALESAMT' TABLE COLUMN as follows

if year(docdate) = year(day()) then
select 'SALESAMT' as currentsale from SALES
end if
if year(docdate) = year(day()) - 1 then
select 'SALESAMT' as previoussales from SALES
end if

Please let me know how I can give the above condition in one SQL.

With thanks
Pol
 
P

pol

The report I want to make as follows

Previous Year Current Year Preamount Curramt
Diff

01/01/2008 01/01/2009 500 700
200
02/01/2008 02/01/2009 300 100
-200

It would be very helpful if anybody can provide a solution in Access
 
J

John W. Vinson

The report I want to make as follows

Previous Year Current Year Preamount Curramt
Diff

01/01/2008 01/01/2009 500 700
200
02/01/2008 02/01/2009 300 100
-200

It would be very helpful if anybody can provide a solution in Access

You'll need a "Self Join" query, adding the table to the query TWICE. In order
to do so you need some way to identify which previous-year record goes with
any given current-year record. What's actually in your table? Do you have one
record per month, or one record per day, or many records per year with no
particular date limiting? More info please!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top