Access 2010 Database - Count number of instances - database

I'm a complete Access noob and I'm creating a database to keep track of orders shipped for work. I've got two tables in the database, one keeping track of the units shipped and the other keeping track of each purchase order and how many more items until that order can be closed. What I want to do is, basically, like a COUNTIF function from Excel on the entries from Table A and transfer to Table B. An example:
Table A has:
PO123
PO123
PO234
PO123
What I want Table 2 to do is count the number of instances of each PO and display the count in a field, like so:
Table B:
Row 1 Field 1: PO123
Row 1 Field 2: 3
Row 2 Field 1: PO234
Row 2 Field 2: 1
Anyone have any ideas? Any help is greatly appreciated.

You didn't say what the name of the field was, so I'm going to assume it's POTYPE. You need to create a query in Access, and go to the SQL view. Then you can do a query like
Select POTYPE, Count(POTYPE) From TableA Group By POTYPE

Related

Reorganize ID of tables in postgreSQL so that the ID starts again at 1?

Hello i am currently try different data automation processes with python and postgreSQL. I automated the cleaning and upload of a dataset with 40.000 data emtries into my Database. Due to some flaws in my process i had to truncate some tables or data entries.
i am using: python 3.9.7 / postgeSQL 13.3 / pgAdmin 4 v.5.7
Problem
Currently i have ID's of tables who start at the ID of 44700 instead of 1 (due do my editing).
For Example a table of train stations begins with the ID 41801 and ends with ID of 83599.
Question
How can reorganize my index so that the ID starts from 1 to 41801?
After looking online i found topics like "bloat" or "reindex". I tired Vacuum or Reindex but nothing really showed a difference in my tables? As far as now my tables have no relations to each other. What would be the approach to solve my problem in postgreSQL. Some hidden Function i overlooked? Maybe it's not a problem at all, but it definitely looks weird. At some point of time i end up with the ID of 250.000 while only having 40.000 data entries in my table.
Do you use a Sequence to generate ID column of your table? You can check it in pgAdmin under your database if you have a Sequence object in your database: Schemas -> public -> Sequences.
You can change the current sequence number with right-click on the Sequence and set it to '1'. But only do this if you deleted all rows in the table and before you start to import your data again.
As long as you do not any other table which references the ID column of your train station table, you can even update the ID with an update statement like:
UPDATE trainStations SET ID = ID - 41801 WHERE 1 = 1;

How to manipulate dataset to get information from different tables?

Currently my data is set up as a union of two tables. The red rows are Table 1 and the blue rows are Table 2. I am doing my union in SQL Server and am connecting this into Tableau. I am using Excel right now to depict what I am seeing (left pivot table) more easily and what I want to see (right made-up pivot table).
The current pivot table is showing when filtered on a particular Plant/Project/Product, those are the components that go into the Product and those are the months in which the Products are due to the customer. The values in the bottom row are the quantity of the Product that is due to the customer. For example- in June, a quantity of 1 of the 150-100020-1000 product is due to the customer. The quantities are showing up under a null component because that field isn’t in Table 2, as you can see in the blue rows.
I want those bottom row values to appear under literally any one of those components that are listed. In this case, it’s only showing one set of Plant/Project/Product, but I would want the formula/code to pick up on that too when it’s evaluating what to output. In the example on the right side made-up pivot table, I have the quantities showing up under the component #100, but it can be under any of them as long as the Plant/Project/Product is equal in both tables. I also don't want the blank/null dates from Table 1 to show up, but they are tied to the components so I can't filter them out easily.
I've tried several types of joins and temporarily tables to get this working and keep coming up blank. How can I set up my dataset to get the view I want to see in Tableau?
Dataset and Current View + View I Want
Your problem is you don't have a Component against a Qty. Hence for what you want somehow you need to create a Component. Perhaps this is possible using a FIXED calc, which would create this field across all records. If the value of Component doesn't matter create this calculation:
{MIN([Component])}
This should put 100 against each record.
If you also need to keep the existing Component value, when it exists, try a formula such as:
IFNULL([Component],{MIN([Component])})
Note I haven't tested any of this.

Is it possible with Mongo DB to select data based on 2 IDs in Mondo DB document?

I have an array dataset ( first column is list of cities, second and other columns contain distance between selected city from first column and selected city in second and other columns ).
Tried to use many to many relationship in SQL Server, but it seems to complicated and nearly impossible.
For now i have 2 options for implementing main task.
My main task is to select distance between 2 cities based on 2 dropdown selections, which data source is city from fitst column and selected city in second and others column.
Is it possible in Mongo DB to solve this task ? I am not sure, if i can query a bson document based on 2 IDs ( first ID is city from first column and second ID is city from other column ).
Please help

Merge two tables into a single indexed view in SQL Server 2008

So here is my dilemma, I'm currently storing all my records into a giant flat table that has movies, episodes, series, games etc. 70% of the records are episodes that I do NOT want indexed by the default full-text catalog as they make up over 2 million of the records and 90% of the time people are searching for movies/series, so I want to move these records into a separate table so they can have their own separate full-text catalog and a few additional columns that do not apply to movies/series (season, episode # etc.) as well.
My issue is with stored procedure I use to checkTable if an ID already exists before I go and download data or update data for that ID.
I wanted to create a view of all the ID's across both tables so I could lookup in a single place if that ID exists, however when I try to union the tables it will not allow me to create an index on the view.
ID Type | ID Type
1 movie | 2 episode
3 movie | 4 episode
5 movie | 6 episode
The ID's are unique and will never have duplicates in either table.
I feel that since this view will have over 2 million records an indexed might be important being it is called over 250-500+ a second so optimization is a huge factor.
Is there a better approach than using UNION ALL to get ID's 1,2,3,4,5,6 into a single view?
Probably your best solution is to create a view that does UNION ALL of the two tables, but instead of trying to index the view, make sure you have a good indexing strategy implemented on the tables themselves.
You can use Index Hints in your view to force the view to use those indexes whenever someone selects from the view.

How to maintain the relation ship on more than two tables

Please help me on maintaining the relatoinships between more than two tables. I will explain the one scenario that i am facing now.
Table 1 has all the codes i am using in the application, example status codes means Active has the code as 10, InActive has the code as 20, in this way i am mainting all the codes,
Table 2 is having the 5 columns,
column 1 is auto generated key
column 2 - has the id of table 1
column 3 - also has the id of table 1
column 4 - also has the id of table 1
column 5 - has description.
So,I need to perform multiple joins while retreiving the data from these two tables.My question is this, is it right way to maitain the tables?
Moreover i am using Spring with Hibernate to fetch the data from DB. Any ideas on how to do that using Hibernate?
Please suggest me on this.

Resources