Ok here is my dilemma and I am sure more experienced Access users have an easy solution. I have been manually running a set of queries to pull data for business users, that I want to create a form for so they can just run it themselves. This would be easy if it was one query, but the way I have to pull the correct data is first have to run one query that creates a table. I then use that 'new' table in a secondary query to get the data I need.
That first make table query needs to take inputs like supplier number and date range. I then use that output table in another query that sums up total dollar value of purchase orders. I can not include these two steps in one query as it creates an ambiguous outer join.
Any ideas on how I would go about creating a form for something like this?
Well after re-thinking this I think I was OVER thinking it. Instead of creating a table in the first step, I can just save it as a query and join that query to the second query. Then make a form off the two queries.
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'm trying to create a query that will return all of the customer ID's from multiple tables as well as the monetary amounts that go with each of the customer codes. However, instead of pulling in every customer code from each of the tables in the query, it only pulls in a random selection of the codes. Any idea what could be causing this to happen? I apologize if I explained it poorly, if you have questions ask away. I've also attached a snapshot of the query design view below.
query design image
You are using INNER JOINS in your query, which means only rows that exist in all joined tables are returned. So if you have a customer that purchased items in 2014 but not 2015, then their name will be excluded.
If I understand what you are attempting, you want to use LEFT or RIGHT Joins, which will return all rows from KNOXLIVE_SLCUSTM and only rows from the other tables when a match is found.
So if you do not know SQL, right-click each join line in the query designer, and select join properties.
Depending on which order the tables were initially added either the second or third radio button will be the join you want. Choose the one that selects ALL records from KNOXLIVE_SLCUSTM. Do that for all four joins and re-run your query.
I am curious if it is possible to limit the results of an sql select statement by joining another table with selectable options. ie. Have one table that a user can use to update their preferences such as display a,c,d and do not display b and e. (assuming the table would only have columns a-e) (this has is separate from the question). Once the user has updated / selected their options im curious if i can create an sql select statement that would fetch the results of another table based off of the options selected by the user in the first table. I know can can create a larger statement that would include all of the results and omit them if the value is not provided. im curious if there is a way to only select particular columns based off of another table
im curious if there is a way to only select particular columns based
off of another table
No. Queries cannot have varying columns. Technically, you can make a stored procedure do something like that; but it is considered a rather poor practice.
...and doing it the right way is likely not going to be a "larger statement".
I have joined 5 tables and done transformation on these tables. Now I got a single table at the end. Now I want to perform sql query on this single table to filter records. But I don't know how to perform simple sql query on this table. I have attached a snap shot which shows the resulting table. How I get this resulting data set as the source? I want to populate my destination after filter out this data.
I am using SSIS 2008.
Click here to see the Table on which I want to perform a simple sql query
SELECT * FROM `first_table`
where `some_column` =
(
SELECT `*`
FROM second_table
WHERE
`some_column2`='something'
LIMIT 1
)
Try this code This will help. You can even use this to connect all those four tables with each other.
From the image you posted, it looks like you have a set of data in the dataflow you're trying to query against. You need to do one of two things at this point. Either you insert the data into a table in the database and use another data flow to query it, or you use use a conditional split (or multicast and conditional splits) to filter the rows down further from there.
Without more detail about what you're actually trying to accomplish, these are the recommendations I can determine.
You could send the rows into a record set destination, but you aren't able to query it like a regular table and you'd need some C#/VB skills to access it to do more than a FOR EACH loop.
Assuming your sql query that you want to run against the resulting table is simple, you can use a script component task. By simple, I mean, if it is of this nature:
SELECT * FROM T WHERE a = 'zz' and b = 'XX' etc.
However, if your query has self joins, then you would be better of dumping the outcome of joining those 5 tables in to a physical table, and go from there.
It appears that query is going to be real straight-forward; in that case using a script component would be helpful.
A separate question: It's advisable to do the sorting at the database level. You are using 5 sort tasks in your solution. Can you please elucidate the reason?
Let's say that we have one table with a field called sales_total and another table with a bunch of sales entries. Let's also, for a moment, imagine that it is impractical to count the entries every time we want to see the total number of sales.
Is it possible to have MySQL automatically update the sales_total field every time the number of sales entries changes?
I know that you can do this by running another query via C#, PHP or whatever - I'm just curious whether MySQL (or some other database system) can do this within itself?
P.S. This is of course a pretty banal example - the ideal solution should be able to handle more complex operations (storing several rows as a string in a field, etc).
use mysql trigger...
trigger on update from the first table should have some queries to update the second table.