I have table that has users with unique IDs and a date field for when the account was created. I am able to generate a query that can tell me how many people signed-up within a particular week of the year. However, what I am interested in is the number of users that signed up historically + that week. Does anyone have any ideas?
Constraint, I have read only access to the database and can not write new tables and columns.
I've successfully gotten the counts broken up by week, but I can't not figure out how the table can refer to itself to get a running total.
Related
I'm trying to write a query that I can call from with Excel that will return the results from a handlfull of tables in a single list.
I could create the table I need from APPEND and just pull that into excel, but the tables I want in the APPEND will change from time to time and I'd rather just add them into the append than keep creating the tables I need and deleting the ones i don't need.
I have a monthly invoices from a number of clients in tables for each client and month. The total number of invoices per month is ~1m. I started just joining them into one large table but it starts to add up to a massive database quite quickly. Most of the time I'd only need to query the first couple of months but everyone in a while I'd have to go back longer.
What I want to do is have a query for each company that I can alter to pull back varying groups of months, but without actually creating the table.
i.e append
Company A Jan,
Company A Feb,
etc
Is there away to do this in a query without creating an actual table
I needed a UNION query.
I knew it was an issue with terminology.
I have a table that I use for statistical purposes.
Its columns are id and 1,2,3,..,31 and pivot.
This table gives the number of views on each day for the last 31 days.
1 gives the number of views for yesterday.
14 gives the number of views for 14 days ago.
etc ...
(pivot is just used to calculate the number of views)
I would use a cron job every day to update this table, but how would I go about "shifting" all the values to the side ( value column 15 would become value column 16; new value for column 1; delete value for column 31)
Define a table with only two columns — "date" and "views"
INSERT a new row in the table with the view count for that day when the CRON job runs
Modify your application query to read through this new table over a custom date range, which could be 31 days or anything else either — please have a look at this link to get an idea:
MySQL Query - Records between Today and Last 30 Days
Not really sure how pivot is being used here. However, I'm almost certain that if you're using it to store the sum of the views, it could as well be computed by using SUM() or GROUP BY without having to need a separate column in the table
As far as data archival / removal is concerned, your daily CRON job could be modified to include a DELETE query (as the last step) which cleans up records older than a certain date. Again, you could use the link above to get your "target" date
.
I apologise that this might sound like a little too long a solution to what you've asked for. However, I feel, this approach should help you organise and maintain the table in question in a better way.
I am writing a script which will counts the number of ticket as per as different conditions and store the count in a summary table. I am unable to understand how to structure my table since there will be more than 1 variables.
The script will run every week and with each execution a new week will be added. Once the new month starts and scripts execute, a new month will be added and once new year starts a new year will be added. So in a nutshell I have columns which are also variables. Not sure how to handle it and structure my db.
Have columns Date Service Count.
Like so.
Date Service Count
16 May 2016 Service1 35
Then when you go to display them in the report pivot them as you want. Probably better to make date an INT and either an auto number PK or composite PK of Date and Service.
Wrong approach. Do not splay an array across columns. Instead have rows for the data. This lets you trivially "add" another month.
For displaying, well that is an application problem, no a MySQL problem. Sure, you can write specialized queries to "pivot" the data from rows to columns, but it is messy.
I'm trying to make a master table in ms access that constantly updates the records of the unique model numbers based upon the most recent date.
The premade table was created by using a select query that brings all the records of multiple tables and inserts them into a single table. Within each table there are multiple fields however the only relevant fields are the Model number field and the Date. Across the tables the unique model numbers are repeated, but their individual time stamps are different.
I need the master table to select the records with the most recent date and place the whole record into the master table. I'm new to ms access and I don't know how I could do this. Any tips of suggestions would be most appreciated.
If you would need such a table then I'd say there's definitely something wrong with your database design.
Having said that, why don't you query on the most recent date of tables that hold Model Numbers?
It might help if you could elaborate on why you'd want to do this, as in why you have multiple tables that hold Model Numbers.
Maybe your current database design is open for improvement.
Kind regards,
Rene
I have a database for our local real estate listings, there are no dates or timestamp columns.
I would like to be able to get out just the rows that were added in the past day or two.
Can anyone point me in the right direction to get this data out?
EDIT:
Each new row does get a new id number which is incrementally higher, so I can ORDER the results by newest.
Would it be possible to save my query count in a file, or in another database, each day, then calculate the difference and use that as my number of new listings?
"Would it be possible to save my query count in a file, or in another database, each day, then calculate the difference and use that as my number of new listings?"
I understand that you can't change the table structure to add a date...so instead, I suggest to have a cron job at midnight that will create a record with a date and the higher ID at this moment. This way, you will be able to finde a range of ID for a specific date...
If you relayed on query count, you will get problem when you will start to delete some rows...