Hi, I'm new to MS-Access. My apologies in advance, this is probably a basic question asked and answered but I don't know how to word the search to find the right results.
I have this query on MS-Access. Is it possible to create a query only with the sum value, 662766.48??? Below is my code.
SELECT Sum(T.DollarsSold)
FROM T
HAVING (((T.Year)="2017") AND ((T.Period)="08"));
My ultimate goal is exporting only the sum value of a query to a specific cell in an existing excel spreadsheet. And I thought It'd be easier to have just a sum value on a query and export it to excel.
Just sum the DollarsSold column, and change the HAVING to WHERE, since you're getting rid of the GROUP BY:
SELECT sum(DollarsSold)
FROM Table_S
WHERE Year="2017" AND Period="08";
Related
Apologies if asked elsewhere, having checked couldn't find anything. I've got a SQL driven table in Excel. When my table refreshes, resulting in no data, it completely clears out a series of none-SQL driven columns on the far right of the table. Is there any way at all I can force Excel to store the formula on the cell, regardless of whether the row has cleared?
To ellaborate on my comment:
Below shows a simple query returning 10 dates from a database. The right column is a simple formula in excel adding 10 to the date:
If I update the query to return the top 0, you find the formula disappears because there are no values to assign the formula to:
But, I then update the query to bring back the original 10 dates again, and hey-presto, the formula re-appears!:
So I wouldn't think that you need to worry that it has gone. I would expect that they would come back once you return some values from your query.
FYI - More help on calculated columns can be found here from Microsoft support.
Thanks! I think I had 'preserve column sort/filter/layout' unticked - which was causing the formula to be lost when the data refreshed! Schoolboy error, thanks again
I have a, hopefully, very simple query, as there may not be a way to do this as its just plain wrong or im overthinking it. Basically I am trying to put together an SQL query for databases that sit on Netezza.
I have an excel document with data featuring unique IDs which I can query manually using the code below, although its not practical to do manually as there are over 9000 IDs. I firstly thought about trying to compile a similar report and just look up against eachother. But I have not been able to reproduce the report (total noob to SQL/netezza). Is there a way of drawing values from a range in excel to execute in an SQL query? Just wanted to check if there was a relatively simple way of doing this or not before giving up.
SELECT * FROM TABLE_1
WHERE UID = '2219788'
AND CURRENT_RECORD =1
LIMIT 100;
I have a table with many entrys but i only want to display the items with quantity over 0. What a query like that would be like? and how do i use it? Complete noob in Access and VBA
Going by just what you said, you can try the following query:
SELECT *
FROM yourTable
WHERE quantity > 0
You need to use a combination of VBA and SQL. I assume you wish to use vba, as you added the tag. A good place to start is here:
http://www.fontstuff.com/access/acctut15.htm
That said if you just want to use the SQL query then Tim's answer has everything you need
I have a query which grabs data from Access with contents:
A,1,z
A,2,z
B,1,y
A,1,i
I created 3 dropdowns in excel and I want to populate them with rows from these columns. The problem is that in each column there are duplicates and I want to get rid of them. I am looking for a solution to get rid of these duplicates.
Current process is following:
run a query. I use VBA in Excel. Access is being queried.
paste results into a separate sheet (it takes A LOT of time because there are 20k reocrds)
assign a range for my dropdows
As you can see my second step is very resource hog and the proccess time should drop drastically by removing duplicates from each column.
What is the best approach to populate dropdowns with unique values from query?
My ideas
create a query which will output me:
A,1,z
B,2,y
, ,i
In that case i will not have to distinct values manually in excel. Not possible to do, as I understand...
Add values from each columns to List, remove doubles, paste result into excel. This is my personal favorite because I see no other ways to fix the issue.
create multiple queries to DISTINCT each table_column separately.. Not very fast solution, I suppose
some other approach
Run three SELECT DISTINCT Colx FROM table queries to get the values for the three dropdowns. Your option two. The work has to be done sometime so you might as well use the tools designed to do the work instead of reinventing that wheel.
If you use select distinct columna, columnb... instead of select columna, columnb... you will get what you want. The SQL will take longer to run, though.
I want to pull data with an MS Access crosstab query so I can bind it to a report. When I load the page I get a Run-time error'3637': Cannot use the crosstab of a non-fixed column as a subquery.
I would like a way to get back a fixed grid when I run the query and if the cell is null display a zero.
Subquery? That's one of my weaknesses when it comes to Access so I can't help you there. I'd suggest posting the SQL of the query though so others can take a look. Also what happens when you run the query?
The following is a query that I'm using to give me costs for the last ten years for a given unit.
TRANSFORM Sum(ServiceRecords.srTotalCost) AS AnnualCost
SELECT ServiceRecords.srEquipmentID
FROM ServiceRecords
GROUP BY ServiceRecords.srEquipmentID
PIVOT "C" & DateDiff("yyyy",[srServiceDate],Date()) In ("C9","C8","C7","C6","C5","C4","C3","C2","C1","C0");
The trick is after the PIVOT. As I want the last ten years worth of data the "C" & DateDiff portion sets up a string variable call C0 to C9. The portion after the In tells which column to stuff things into.
Another query which pulls in data about the Equipment calls this query. The term we generally use for such is stacked queries.
If this isn't enough to get you going please indicate what type of data you are trying to create a cross tab.
Fellow Access MVP, Allen Browne has a good page on this topic. Crosstab query techniques