Select ALL in SSRS - reporting-services

I have a table based on three drop down lists. The first is a client list, the second is a date list and the third is a stage list. The first two are single value lists. I can only allow the user to select 1 from each of those lists. The third list is a stage list. This contains the values First,Final and Release. My client has come back to me and asked if I can supply them with the ability to select all of the stages as an option. Here is the query as I have it right now. I have tried using (AnnotationDate IN (#Stage)) in place of (AnnotationDate = #Stage) but was unsuccessful. Can anyone give me a helpful hint?
SELECT AdDate, Page_ID, Status, AnnotationNumber, AnnotationBy, [Role Description], AnnotationDate, AnnotationType, BusinessUnit, ActualAgencyError, ErrorType,
AnnotationComments, TeamComments, sgkComments, PA, Client, Activity, Support, Name, BusImpact
FROM vwAgencyErrorOpen
WHERE (Client = #Client) AND (AdDate = #Job) AND (AnnotationDate = #Stage)
ORDER BY Page_ID

Change your #Stage Parameter to be multi-seletion.
Then remove the (AnnotationDate = #Stage) clause from the query.
And then set up a filter on your dataset as below:
You can then select all of your options.

Related

Joining 2 tables together and using the where function based on a separate mysql query

I am building a training platform for work. I have created the requirements for a user to be trained based on a role given to them. If that role is aligned to a document it will sit against the user. I have managed to get most of the way but am struglling on the best way to finish the where statement within mysqli.
tbldocfiles is a list of my files. I am looking at docid (could be multiple files associated to the document)
tbltrainingaccess sets the roles (driver, warehouseman, customer services) and shows which role (by id) is associated to the document in docfiles.
tblusertraining is the list of users and what role they have associated to them. (driver, warehouseman, customer services).
I am listing the documents associated to the user so have thought the following is the best way:
Look at the user and how many roles he/she is allocated
Look at the roles returned in point 1 (where function)
Identify and match the documents that have the same roles as the user (Join function)
create the list, then look at the unique values for docid. (distinct value)
Example User Bri has the driver and warehouseman role.
There are 5 documents in the db, 3 of them are associated to the driver role (docid 1,2,3) and 2 of them are associated to the warehouseman role (docid 2,4) the 5th document is associayted to customerservice.
My query should do this:
List all documents associated to the roles, that are associated to the user Bri
1
2
3
2
4
Now select unique values (using docid) from the above list:
1,2,3,4.
So my answer will be a used as a count function at the end using mysql_fetch_rows
SELECT DISTINCT tbldocfiles.docid FROM tbldocfiles LEFT JOIN tbltrainingaccess ON (tbldocfiles.docid = tbltrainingaccess.docid) where groupid='1' or groupid='9'
The above code works. but i've got myself confused.
The where statement needs to be the result of a query similar to :
select * from tblusertrainingrole where userid='1' (1 will be a variable based on page selection)
the result in this would be 1, 9 which are the groupid results.
Basically any help would be appreciated! I am sure it will be simple but have burnt myself out on this for a while and most answers in here helped with joining but not the where statement (that I could find)
Thank you in advance everyone!
You can do a select statement in the where. Since it is an or statement you can use in for the results. Please replace * with the column name for the value you need. Should look like
where groupid in (select * from tblusertrainingrole where userid = '1')

Listbox is not able to show items based on another list

I am currently trying to set up a GUI frontend for easier querying for colleagues.
I have tried researching and following instructions from various sources but still not able to make it work.
I have two lists.
1) This is the row source query for the first list(List0):
SELECT Test_Case_ID.Test_Case_Unique_ID, Test_Case_ID.Test_Case_Description
FROM Test_Case_ID
ORDER BY Test_Case_ID.[Test_Case_Description];
2) This is for the second list(List2):
SELECT Reference_ID.Reference
FROM Test_Case_ID INNER JOIN (Reference_ID INNER JOIN Test_Result
ON Reference_ID.Reference_Unique_ID = Test_Result.Reference_Unique_ID)
ON Test_Case_ID.Test_Case_Unique_ID = Test_Result.Test_Case_Unique_ID
WHERE (((Test_Case_ID.Test_Case_Description)=[Forms]![Form1]![List0]));
I have a an event procedure for List0:
Private Sub List0_AfterUpdate()
Forms![Form1]![List2].Requery
End Sub
However, there are no outputs on List2 even after clicking on items in List0. Can I have some advice to fix it? Thank you
Firstly, check that the bound column of your list box List0 corresponds to your Test_Case_Description field.
With the form open and populated with data, you can also run a number of tests 'manually' by creating a separate query containing the SQL for your list box row source and verifying whether or not it returns any results:
select
reference_id.reference
from
test_case_id inner join
(
reference_id inner join test_result
on reference_id.reference_unique_id = test_result.reference_unique_id
)
on test_case_id.test_case_unique_id = test_result.test_case_unique_id
where
test_case_id.test_case_description = [forms]![form1]![list0]
You can also use a query with the following SQL code to test the value returned by [forms]![form1]![list0] and ensure that it returns the value that you expect for use in your selection criteria:
select
t.test_case_description,
[forms]![form1]![list0] as listboxvalue,
t.test_case_description = [forms]![form1]![list0] as testmatch
from
test_case_id t

How to create a view?

I'm pretty new in App Maker. I want to create an app that will collect various types of request (failures, new ideas, orders and so on ). For each type of request will be separate data model. Every data model (request) contains 3 the same information: date, applicient, comments.
In addition to the dashboard's stand for each type of request, I want to make one in which all entries will be displayed with only repating records and type of request as one more record (date, applicient, comments, type of request)
I think that Calculated Model is the answer here, but despite getting acquainted with the documentation, I don't know how to implement this in my case. Could anybody halp me with this ?
Below I am presenting the display of the above description. Records 1, 2, 3 ... presents records that don't replicate in another data model.
IMAGE:
https://drive.google.com/file/d/1gi6ylZacOVSkcqtpaupRpIOrzbq7fOsT/view?usp=sharing
I tried to do relations, but I couldn't displey this in one table, what is my goal. How to conigure the SQL datasource to do this ?
You can create a new calculated SQL model with UNION:
(SELECT 'Failures' AS REQUEST_TYPE, C.* FROM Failures AS C)
UNION ALL
(SELECT 'New Ideas', C.* FROM `New ideas` AS C)
UNION ALL
(SELECT 'Orders', C.* FROM Orders AS C);
You must have corresponding fields in your datasource that match the sql column names: REQUEST_TYPE, Date, Applicient, Comments
Reference:
Cloud sql model

MySQL: showing totals

I am trying to figure out how to have PHP check and print 2 different functions.
Both of these questions are referring to table called "remix".
The first, and more important problem at the minute, is I would like to know how to show how many DIFFERENT values are under "author", as to compile the amount of total authors registered. I need to know not only how to most efficiently use COUNT on returning UNIQUE names under "author", but how to show it inline with the total number of rows, which are currently numbered.
The second question would be asking how I would be able to set up a top 3 artists, based on how many times their name occurs in a list. This also would show on the same page as the above code.
Here is my current code:
require 'remix/archive/connect.php';
mysql_select_db($remix);
$recentsong = mysql_query("SELECT ID,song,author,filename FROM remix ORDER by ID desc limit 1;");
$row = mysql_fetch_array($recentsong);
echo'
<TABLE BORDER=1><TR><TD WIDTH=500>
Currently '.$row['ID'].' Remixes by **(want total artists here)** artists.<BR>
Most recent song: <A HREF=remix/archive/'.$row['filename'].'>'.$row['song'].'</A> by <FONT COLOR=white>'.$row['author'].'</FONT>
So as you can see, I have it currently set up to show the most recent song (not the most efficient way), but want the other things in there, such as at least the top contributor, but don't know if I would be able to put it all in one php block, break it, or be able to do it all within one quarry call, with the right code.
Thanks for any help!
I'm not sure I really understood everything in your question but we'll work this through together :p
I've created an SQLFiddle to work on some test data: http://sqlfiddle.com/#!2/9b613/1/0.
Note the INDEX on the author field, it will assure good performance :)
In order to know how to show how many DIFFERENT values are under "author" you can use:
SELECT COUNT(DISTINCT author) as TOTAL_AUTHORS
FROM remix;
In order to know the total number of rows, which are currently numbered you can use:
SELECT COUNT(*) as TOTAL_SONGS
FROM remix;
And you can combine both in a single query:
SELECT
COUNT(DISTINCT author) as TOTAL_AUTHORS,
COUNT(*) as TOTAL_SONGS
FROM remix;
To the top 3 subject now. This query will give you the 3 authors with the greatest number of songs, first one on top:
SELECT
author,
COUNT(*) as AUTHOR_SONGS
FROM remix
GROUP BY author
ORDER BY AUTHOR_SONGS DESC
LIMIT 3;
Let me know if this answer is incomplete and have fun with SQL !
Edit1: Well, just rewrite your PHP code in:
(...)
$recentsong = mysql_query("SELECT COUNT(DISTINCT author) as TOTAL_AUTHORS, COUNT(*) as TOTAL_SONGS FROM remix;");
$row = mysql_fetch_array($recentsong);
(...)
Currently '.$row['TOTAL_SONGS'].' Remixes by '.$row['TOTAL_AUTHORS'].' artists.<BR>
(...)
For the top3 part, use another mysql_query and create your table on the fly :)

Select statement help needed

I am writing a query in a mysql db website and need a little help on the select statement syntax. I need to retrieve info from a database containing user input from a web-form at my site. There are a large number of over-the-road drivers who need to check in reporting their location with this form. The goal is to have a concise grid display table on the resulting web page that shows only the latest entry for all the drivers with only the 3 criteria on each row, (– name – location – date/time). The code included below does return results for all the drivers, but in the form of a long list of all entries for each driver on multiple pages instead of just updating location for each driver. It seems like I need to use “DISTINCT” and/or “LIMIT” in the string, but my attempts at this haven’t produced the desired results.
Thanks, Mike
$myquery = "select name, location, recordtime from ".$config->site_db."form_db order by recordtime DESC";
If I understand correctly you want to select the record with the highest recordtime for each name:
$myquery = "select name, location, max(recordtime) from ".$config->site_db."form_db group by name";