to give if condition in MS Access

  • Thread starter Thread starter pol
  • Start date Start date
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
 
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
 
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!
 
Back
Top