Subtracting 2 sub queries in SSRS as an expression - tsql

I am trying to subtract 2 sub string to get a backlog of application and i am getting stuck. Can someone help me out here. The SSRS expression i am trying to write is below. What am i doing wrong?
The query will execute but won't subtract to 2 sub strings:
=SUM(IIf(Fields!NAME.Value = "TOTAL OUTSTANDING APPLICATIONS"
, Fields!DAYS_AGO.Value
, Nothing)) - SUM(IIf(Fields!NAME.Value = "ELECTION FORM RECEIVED"
, Fields!DAYS_AGO.Value
, Nothing))

Your problem is that you are aggregating NULL values with your data which results in NULL.
As long as the rest of your logic is correct, it should work if you replace the Nothings with 0.
=SUM(IIf(Fields!NAME.Value = "TOTAL OUTSTANDING APPLICATIONS"
, Fields!DAYS_AGO.Value
, 0)) - SUM(IIf(Fields!NAME.Value = "ELECTION FORM RECEIVED"
, Fields!DAYS_AGO.Value
, 0))

Related

how to delete automatic date if more than 5 minutes using codeigniter

how to delete automatic date if more than 5 minutes
$time = 1;
$deletetoken = "DELETE FROM log aa LEFT JOIN user bb ON aa.`email`=bb.`email`
WHERE aa.`code_aktivasi`='code_aktivasi'
DATEDIFF(CURDATE(), create_at)-> $time";
$run = mysql_query($deletetoken);
I want automatic date if more than 5 minutes,
But it is not working, what might be happening?
Here's my suggestion, hoping it helps you to solve the problem.
$sql = "DELETE FROM log l LEFT JOIN user u ON l.`email`= u.`email`
WHERE l.`code_aktivasi`='code_aktivasi' and `create_at` < (NOW() - INTERVAL 5 MINUTE)";
$run = mysql_query($sql);
You can use l.create_at or u.create_at for matching your purpose.
If it's still not working, please show me the error message.

For each loop for a table in OpenEdge 10.2b takes more time

Below for each loop takes more time and i cant able to trace index usage using XREF as the table uses Oracle Schema.Please Help me.
Need to generate report for different Report Type ( Report type is the input parameter in my code ).Single report type may contain more than 50,000 records how to access all the record within minute.Index detail also mentioned below for each loop.
FOR EACH Report
FIELDS(EXTRACTDATE STATUS MailingType ReportType ReportNumber
RequestID CustID)
WHERE Report.EXTRACTDATE < Today
AND Report.ReportType = 'Customer Report'
AND Report.STATUS = 'Pending'
AND (Report.MailingType = "LETTER"
OR Report.MailingType = "Mail") NO-LOCK:
< Statements >
.
.
END.
**Index Detail**
CREATE INDEX "TYPE_IDX1" ON "Report" ("EXTRACTDATE" DESC, "ReportTYPE", "STATUS", "MailingTYPE", "PROGRESS_RECID")
CREATE INDEX "REQ_IDX1" ON "Report" ("REQUESTID", "PROGRESS_RECID")
CREATE INDEX "RTTYP_IDX1" ON "Report" ("ReportTYPE","PROGRESS_RECID")
The "OR" at the end will slow things down considerably - the AVM does better if you split it up into two sets of AND statements and OR the result, like so:
WHERE (Report.EXTRACTDATE < Today
AND Report.ReportType = 'Customer Report'
AND Report.STATUS = 'Pending'
AND Report.MailingType = "LETTER")
OR
(Report.EXTRACTDATE < Today
AND Report.ReportType = 'Customer Report'
AND Report.STATUS = 'Pending'
AND Report.MailingType = "Mail")

Add record to table, and edit records in 2 separate tables

Hi there I'm making an access database, and I can't figure out how to do one particular thing.
I've got a form with two text boxes: MovieID and CustomerID. I also have three separate tables: MovieList, CustomerInfo and HireHistory. What I need is so that when I enter a MovieID and CustomerID into the given boxes then press my button HireButton, it edits that specific MovieID's LastHireDate to Today(), edits that specific CustomerID's LastHireDate to Today(), and then in my HireForm (which has the CustomerID's in the first row) it adds a new record below the CustomerID in the form of: MovieID " on " Today()
Also, I need to make it so that it checks that MovieID's genre and if it's R16 or R18, then it checks whether the customer is older than 16 or 18 today, and if not then it comes up with an error box. I know how to do the checking whether they are older than 16 or 18, but not the error box.
I know that's a lot of text, so I'll just write what's in my brain (how I see the code should be) so it will be easier to see what I want to do.
IF MovieID.Rating = 'R16' OR 'R18'
THEN IF CustomerID.[Date(Year(DOB)+16,Month(DOB),(Day(DOB))] > Today()
THEN DISPLAY Msgbox = "Sorry, too young"
ELSE SET CustomerID.LastHireDate = Today()
SET MovieID.LastHireDate = Today()
ADDRECORD in HireHistory for that CustomerID to (MovieID & " on " & Today())
ELSE SET CustomerID.LastHireDate = Today()
SET MovieID.LastHireDate = Today()
ADDRECORD in HireHistory for that CustomerID to (MovieID & " on " & Today())
Does that explain it a bit better? Thanks in advance for your help! :)
so here How I would do this. You first have to create a recordset for each of those table.
For the age I would use this function. : http://www.fmsinc.com/MicrosoftAccess/modules/examples/AgeCalculation.asp
customerBirth = yourCode to get the date
If MovieID.Rating = 'R16' OR 'R18' then
If AgeYears(customerBirth) < 16 then
msgbox("Sorry, too young")
else
MyCustomerRecordSet("LastHireDate") = now
MyMovieRecordSet("LastHireDate") = now
MyHireRecorset.AddNew
MyHireRecorset("I don't know what your trying to do here")
MyHireRecorset.Update
end if
Else
MyCustomerRecordSet("LastHireDate") = now
MyMovieRecordSet("LastHireDate") = now
MyHireRecorset.AddNew
MyHireRecorset("I don't know what your trying to do here")
End if
If you have any question just ask.

How to get all records from Crystal Report using default parameter values

I have a Crystal Report which has two paramaters: {?EmailVerifyStatus} and {?Company}. I want it so that when the two paramaters are blank the report gets all the records.
Here is my current code:
(if {?EmailVerifyStatus}='Y' THEN {PREH.udEmailVerify}='Y'
ELSE IF {?EmailVerifyStatus}='N' THEN {PREH.udEmailVerify}='N'
ELSE 1=1)
and
(if {?Company} <> '0' then not (IF "," & ToText({PREH.PRCo},0,'') & "," IN "," & {?Company} & "," THEN 0=1 ELSE 1=1) else 1=1 )
But, it is only returning the records with a 'Y' value.
You have to check if parameters have set a value with the hasvalue() function. Then you can do this:
(not(hasvalue({?EmailVerifyStatus})) or {PREH.udEmailVerify} = {?EmailVerifyStatus}) and
(not(hasvalue({?PRCo})) or {PREH.Co} = {?Company})
I dont understand your second condition ...

LINQ - Query with distinct/GroupBy on multiple properties problem

I have some data stored in an EntitySet of my domainContext where I want to select out just parts of it. Problem is that I'm getting all the CageNames - and not just the "New" ones with the highest date.
This is the data:
SiteId CageId CageName Date
1 ,1 ,Lot1 ,'2011-05-05'
1 ,1 ,LotNew ,'2011-05-06'
1 ,2 ,Lot1 ,'2011-05-05'
1 ,2 ,LotNew ,'2011-05-06'
1 ,3 ,Lot1 ,'2011-05-05'
1 ,3 ,LotNew ,'2011-05-06'
So for each CageId listed I want to return the CageName on the record that has the highest date.
My code trying to do this is here:
Dim CageName As Array
CageName = DomainContext.SiteCageDatas.Where(Function(h) h.SiteId = SiteId) _
.Select(Function(x) x.CageName).Distinct.ToArray()
But this just gives me all CageNames.. Any idea how I should fix this, I guess maybe using groupby or something?
Mind; I'm using VB.NET
I'm doing this now, but that returns nothing :(
CageName = DomainContext.SiteCageDatas.GroupBy(Function(a) New With {a.SiteId, a.CageId}).Select(Function(a) a.OrderBy(Function(b) b.Date).LastOrDefault()).Where(Function(x) x.SiteId = SiteId).Select(Function(x) x.CageName).ToArray()
Try this:
DomainContext.SiteCageDatas.GroupBy(Function(x) x.CageId).Select(Function(x) x.OrderBy(Function(x) x.Date).LastOrDefault()).Where(Function(x) x IsNot Nothing).Select(Function(x) x.CageName).ToArray()