comparing years

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was helped me out about a month ago with this access issue giving me the
ability to compare years. This is the information you gave me

SELECT a.*, b.*
from ((Select CUST from [Sales by Component 2003]
union
select CUST from [Sales by component 2004]) as x
left join [Sales by Component 2003] as a on a.CUST = x.CUST)
left join [Sales by Component 2004] as b on b.CUST= x.CUST;

My question is can I use anything besides alpha letters so my column names
would be say 2003.cust ( in the example above). I am working on another query
where I have a count, receivers, and usage of boxes we have. I would like the
column name to be Receiver.Boxes but I can’t figure out hot to replace it in
the query without getting an error.
 
Hi Jeanne,

Yes, you can use any valid table name for the aliases. Many of us use short
aliases to save typing, but you could replace the a, b, x, aliases with
whatever you like. Just be sure to replace all instances of each of them
with the same substitute, and enclose it in brackets if it includes a space.

If you want to give custom field names to each individual field, you can do
that also, but you will have to type them all out individually in the SELECT
statement (followed by AS and the new name that you want) rather than using
the * to select all fields.

In your case, I think if you replace all a's with 2003, and b's with 2004,
you will get what you want.

HTH, Ted Allen
 
Back
Top