i new to SQL say i have this:
SELECT sum(tonsharvested) as kaapstad2011
FROM T_harvest
where BlockNameID = "Kaapstad" and year(Dateofharvest) = "2011"
it gives me a column kaapstad2011 with sufficient values
why cant i just say
SELECT sum(tonsharvested) as kaapstad2010
FROM T_harvest
where BlockNameID = "Kaapstad" and year(Dateofharvest) = "2010"
to display kaapstad2010 next to column above?
Any advise on how to go further will help, cant seem to shift past this mental block.
Hi,
Give this a try:
Cheers,SELECT Sum(IIf(Year([Dateofharvest])=2011,[tonsharvested],0)) AS kaapstad2011, Sum(IIf(Year([Dateofharvest])=2010,[tonsharvested],0)) AS kaapstad2010 FROM T_harvest WHERE T_harvest.BlockNameID="Kaapstad";
“To sin by silence when they should protest makes cowards of men.” ~ Abraham Lincoln
Nevermind, ConneXionLost's answer is better.
Is your code running too slowly?
Does your workbook or database have a bunch of duplicate pieces of data?
Have a look at this article to learn the best ways to set up your projects.
It will save both time and effort in the long run!
Dave
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks