i'm trying to keep a record of which customers have received which newsletters. I have a query called
TempQuery
I want to take the field
TempQuery.CustID
That consists of several numerical id's and combine it with two static values specified on a form
Forms![frmAddCorrespondence]![txtNID]
Forms![frmAddCorrespondence]![txtDate]
such that I end up with something like
CustID NID Date
1 5 28/03/2011
3 5 28/03/2011
14 5 28/03/2011
56 5 28/03/2011
Again the fields NID and Date will be the same values for each individual insert specified on frmAddCorrespondence and the CustID's are pulled from TempQuery.
I'd like this to be a query from which the data can be inserted into a log table of all our past correspondences.
Any help is greatly appreciated
Thanks, Rob
you want a full outer join between your temp query and the date and ID entered at runtime?
If so, you can pass the two new column values (ID and date) as parameters to your query. Just create a new query based on your existing one and add the two control references as new columns.
Is that what you wanted?
In response to your comment, yes, you can create a second append query in Access that takes all the columns from your query and adds the two parameters from the controls on your form.
Related
I have two tables in Postgresql, which I need to perform the union taking the null values, to add other values in another column of the junction.
Table one:
I filtered by date, because this data is generated daily and I only need the current_date
Table two: All names.
In table two I have 9 names that are not found in table one.
When I try to perform the join, I only get the 9 names from table one as a result.
Trying with date from table one to current_date
But if I don't filter the date from table one, the null value is returned.
That is, the name that is in table two but not in table one.
What I need is to join the two tables and where there is no asset referring to the second table, fill it with 0 (zero).
In this part I understood that I must use COALESCE(vcm.ativo,0).
But first I need the names of the second table to appear as well.
The result should be like this:
If someone could help me, I'll be grateful.
As pointed out in a comment by the asker, the solution turned out to be
with todays_data as (
select vcm.cooperativa, vcm.ativo
from sga_bi.veiculos_coop_mensal as vcm
where data = current_date
)
select coop.nome, COALESCE(vcmm.ativo,0)
from sga.cooperativas as coop
left outer join todays_data as vcmm
on coop.nome = vcmm.cooperativa
I have a multi-value parameter #ID in a report, with 100 values, and I need to collect the values selected in a temp table to further process them, then display the parameters into the report. How can I save the parameters selected into a temp table, one value in each row?
ID:
1
2
3
...
100
Thank you in advance for your help!
If your dataset query is not a stored proc AND they values originally came from a table then you can do this.
Assuming the IDs came from say, a products table, then you could just do
SELECT ProductID INTO #temp FROM myProducts WHERE ProductID in (#ID)
This method is generally basis for most of my dataset queries although I would not use a temp table I would simply query my data and apply the parameter in the WHERE clause as above.
Below i have a table where i need to get fields from one column to three columns.
This is how i would like the data to end up
Column1
Music
Column2
com.sec.android.app.music
Column3
com.sec.android.app.music.MusicActionTabActivity
Give the table a numeric autonumber id
Remove the rows with no data with a select where blank spaces or null
Find records with no point in the content with a select
Use the previous query as a source and use the id to find the id + 1 to find the next record and do the same with + 2 to find the second row
Build a table to hold the new structure and use the query as a source to insert the new created data in the new table with the 3 columns structure.
This is an example using sql server
Test table design
Data in table
Query
Look at the query from the inside. The first query inside clean the null records. Then the second query find the records with out point. This records are the reference to find the related two records. Then the id of the records with out point are used to make a query in the select adding 1 for the next record and then other query adding 2 to find the other record. Now you only need to create a table to insert this data, using this query as the source.
I have an excel sheet with two fields: list of user id, and corresponding create date. I want to query from an external database having around million records by only returning records where user_id in (?). How can i pass a range of id's like $A1:A17 as the single parameter to the query?
One option to achieve the same result using another method would be to create a temporary table with just one column for user_id.
Then you could run the query and do:
where user_id in (select user_id from my_temp_table)
I am trying to create a number of rows in a table based on the value of record in a different table.
i.e Table A has two columns NumberID, Number and TableB has MonthID, Month, Amount
When TableA.Number gets a value of say 5 I want TableB to be updated with 5 new rows. The values of TableB.Month and TableB.Amount will then be entered manually. Can this be done?
Depending upon what database you are using, this can be done using triggers.
Alternately, you could do this in the application layer.