I have a table in the database that has 10 application fields (App#0 to App#9) and their corresponding application versions (appversion#0 to appversion#9)
I have created a new parameter using dynamic cascading that prompts the user to Select an Application: and select the corresponding Application Version:
The value for this fields are taken from App#0 and Appversion#0 respectively.
I want to select all records in the database where application corresponds to the selected App and Appversion. So in the select expert I have used this parameter and it shows me the correct records.
The problem now is- The app that user selects can be in any of the database fields from app#0 to app#9. It is not necessary that it will always be in the app#0 field. So, I want crystal report to check all the database fields from app#0 to app#9 with the parameter that the user selects. How can I do that without creating multiple parameters?
Select Formula expert query
SELECT issue1.reference_id, Software_Products_Anomaly1.product, issue1.description, issue1.last_mod_date, issue1.owner_id,
Software_Products_Anomaly1.application0, Software_Products_Anomaly1.application_version0, Software_Products_Anomaly1.priority, state1.name,
FROM
(splatt.issue issue1
INNER JOIN splatt.Software_Products_Anomaly Software_Products_Anomaly1
ON issue1.id=Software_Products_Anomaly1.issue_id
)
INNER JOIN splatt.state state1
ON issue1.status=state1.id
WHERE
( state1.name='assigned'
OR state1.name='open'
OR state1.name='reassigned'
OR state1.name='submitted'
)
AND issue1.owner_id<>113
AND Software_Products_Anomaly1.product='PHX'
AND
( Software_Products_Anomaly1.application0='Package1' AND Software_Products_Anomaly1.application_version0<='2.2.2.2')
ORDER BY Software_Products_Anomaly1.priority
Related
I'm trying to find out which partners has not paid the monthly tuition in a particular month.
I have a table called Socios containing all partners names SocioNome and another table called RegistroPagamento contaning all payments done (This particular table is fulfilled by a form where the user input the Partner Name, Amount Paid and which particular month/year the payment is related to).
I have created a query where I used the SQL code below:
SELECT [SocioNome]
FROM [Socios] NOT IN
(SELECT [SocioNome] FROM [RegistroPagamento] WHERE [MesBoleto] = [Forms]![Selecionar_MCobranca]![TBoxMes] AND [AnoBoleto] = [Forms]![Selecionar_MCobranca]![TBoxAno]);
[Selecionar_MCobranca] is the form I have mentioned before and the [TBoxMes] & [TBoxAno] are the combo boxes from the form which the user can select the month and the year the payment refers to.
When I run the code, a error message pops up indicating that there is a FORM clause syntax issue, and I don't know exactly what is causing the problem.
NOT IN is a comparison operator in the WHERE clause. It does not belong in the FROM cluase. I strongly recommend using NOT EXISTS instead. The idea is:
SELECT s.SocioNome
FROM Socios as s
WHERE NOT EXISTS (SELECT 1
FROM RegistroPagamento as rp
WHERE rp.MesBoleto = [Forms]![Selecionar_MCobranca]![TBoxMes] AND
rp.AnoBoleto = [Forms]![Selecionar_MCobranca]![TBoxAno] AND
rp.SocioNome = s.SocioNome
);
NOT IN returns no rows if any row in the subquery is NULL. To protect against this, just use NOT EXISTS. It has the expected behavior in this case.
I have two separate tables in my access database, which both use a third table as the reference for one particular field on each table. The data is entered onto the different tables by separate forms. Then I have several queries that then reference those particular fields that count and show unique values. Those queries show the actual values, then I created an sql query that does the same thing, only it shows the reference ID instead of the value in the actual field.
table ODI----------table CDN----------reference table
id RHA---------id CHA----------------id HA
1 blank----------1 radio---------------1 internet
2 internet-------2 tv------------------2 radio
3 referral-------3 radio---------------3 referral
4 tv-------------4 blank---------------4 repeat customer
5 blank----------5 internet------------5 tv
6 internet-------6 referral------------6 employee
7 referral-------7 referral------------7 social media
this is the code I am trying to make work.
SELECT m.[Marketing Results], Count(*) AS [Count]
FROM (SELECT RHA as [Marketing Results] FROM ODI
UNION ALL
SELECT CHA as [Marketing Results] FROM CDN) AS m
GROUP BY m.[Marketing Results]
HAVING (((m.[Marketing Results]) Is Not Null))
ORDER BY Count(*) DESC;
and what my desired result is,
Marketing Results--Counts
referral------------------4
internet------------------3
radio---------------------2
tv------------------------2
Lookup fields with alias don't show what is actually stored in table. ID is stored, not descriptive alias. Lookup alias will carry into regular queries but Union query only pulls actual stored values. At some point need to include reference table in query by joining on key fields in order to retrieve descriptive alias. Options:
in each UNION query SELECT line, join tables
join UNION query to reference table
join aggregate query to reference table
Most experienced developers will not build lookups in table because of confusion they cause. Also, they are not portable to other database platforms. http://access.mvps.org/Access/lookupfields.htm
Short background information;
I receive notification emails with an alphanumeric number, a status field, the email receiving time and the sender name.
I have a database which I populated with these outlook emails. E.g.:
Number status receivingtime sender
Xyz12345 new 22.01.2019 20:22:16 abc
Xyz5683 new 23.01.2019 15:45:55 abc
Xyz12345 closed 23.01.2019 14:32:30 abc
Xyz8765 new 24.01.2019 16:55:32 abc
Xyz9999 closed 2t.01.2019 09:10:11 abc
I need a query (number,status,time,sender) which extracts only the new items if they where not already set to status closed.
In the above given example the extracted data should be xyz5683 and xyz8765
I tried already doing this with for loops which I don't really like as the performance is bad.
I also tried this with populating 2 datatables and joining them together, used except within linq. Due to the fact that I like to store it anywhere for further use I also skipped this method. I would prefer
1.) importing all the emails to the access db
2.) Query them as needed
I read tons of articles with different solutions, but can't figure out how to do this....maybe I already got stuck because I'm thinking way too difficult.
Do you have any ideas how I can do this?
You mentioned Access, so my first solution will give you what you want to see.
At the top of your screen on the ribbon/toolbar, you can create a query. Create > Query Design > Close button > SQL View on ribbon.
First, create a new query called "closed" with the SQL as:
Select Distinct [Number] From status_table where status = 'closed'
Then, create what is called a mismatch query:
Select st.[Number], st.status, st.receivingtime, st.sender From status_table as st
Left Join closed as cls on st.[Number] = cls.[Number]
Where cls.[Number] Is Null;
The query will only show rows which are not closed. You can also try the "Find Unmatched Query Wizard" and follow the steps to remove closed items from your list. You will still need to create the query called "closed" before running the wizard.
If you have SQL Server, you can do this in one query:
With cls As --closed items
(Select Distinct [Number]
From status_table where status = 'closed')
Select st.[Number], status, receivingtime, sender From status_table st
Left Join cls on st.[Number] = cls.[Number]
Where cls.[Number] Is Null;
This example is for Microsoft T-SQL but you can do similar queries in other database types like Oracle, with slightly different syntax. Performance should be good in most environments.
I am working on administering an "erp type" VB program which is running on SQL Server 2008 R2. This program allows users to have a card for each file stored in its vault. Those cards are built into administration tools and u can add elements like comboboxes, dropdownlists etc. You can also add an SQL query into a dropdown list. So i have these 2 tables in SQL Server database:
USERS:
USERID / NAME / USERGROUPID
and
USERGROUPS:
USERGROUPID / USERGROUPNAME
I want to add 2 dropdown lists in my cards connected to SQL with query but i want the 2nd one to be connected with the selection from the 1st one. The 1st one asks for the usergroup name and the 2nd one asks for the name in the previously selected usergroup.
I found out that the 1st dropdown list should be:
SELECT USERGROUPNAME
FROM USERGROUPS
The 2nd one should be like:
SELECT NAME
FROM USERS
INNER JOIN USERGROUPS ON USERS.USERGROUPSID = (USERGROUPS.USERGROUPID FROM PREVIOUS SELECTION)
How can I modify the 2nd query in order to get the data I need?
You can use the following query for second one. It will select all NAME that matches with the GroupName you selected
SELECT NAME
FROM USERS usrs
INNER JOIN USERGROUPS usrgrps ON usrs.USERGROUPSID=usrgrps.USERGROUPID
WHERE usrgrps.USERGROUPNAME='VALUE FROM DROPDOWN 1';
I'm trying to develop some code which pulls latest information only.
What it is when a user goes into a form there a subtable and everytime they change something it creates a new row in the colum called type12_OriginalNoteID which puts its own unique number in. Another field called type12_OriginalNoteID keeps the same number - which keeps track of what the orginal number was before any changes were made.
I do have some code which does pull the latest information but it does not pull anything if the user has not made any changes to the form - and thats because the type12_OriginalNoteID is null.
The code is as follows :-
WHERE ea.type12_NoteID IN
(SELECT TOP 1 ea.type12_NoteID
FROM UserAssessv1aidsadaptations ea1
WHERE ea.type12_NoteID = ea1.type12_OriginalNoteID
ORDER BY ea.type12_UpdatedDate DESC)
An example of the data is as follows :-
type12_note ID 12
type12_OriginalNoteID NULL
type12_UpdatedDate 11/03/2010
What would be the solution to show the information if no one has made any changes to the subtable? - adding an if statement to run if type12_OriginalNoteID is null??
What you need, is to join the two tables using a LEFT JOIN. So the record data from the main table will be still there, but the fields coming from your second table (= subtable) would be null. Your statement should look something like:
SELECT TOP 1 t1.type12_NoteID
FROM t1 LEFT JOIN t2
ON t1.type12_NoteID = t2.type12_OriginalNoteID
ORDER BY t1.type12_UpdatedDate DESC