Remedy - BMC - Excluding Users with Last Modified By - remedy

I am trying to build a search string in Remedy,
I am looking for all open Orders submitted more than 5 days ago, and in which the last updater is not one of the 8 members of our team.
I have the below (and yes, I know it's clumsy, I am a beginner)
(('Status*' = "Assigned") OR ('Status*' = "Pending") OR ('Status*' = "Waiting Approval") OR ('Status*' = "Planning") OR ('Status*' = "In Progress")) AND ('Submit Date' <= ($\TIMESTAMP$ - (112 * (60 * 60)))) AND ('Last Modified By' != "User 1") AND ('Last Modified By' != "User 2") AND ('Last Modified By' != "User 3") AND ('Last Modified By' != "User 4") AND ('Last Modified By' != "User 5") AND ('Last Modified By' != "User 6") AND ('Last Modified By' != "User 7") AND ('Last Modified By' != "User 8")
I would appreciate if someone could take the time to give me a hand.

the qualification for the date is in seconds, so you need to tell "current time minus 5 days".
('last submit date' < ( $TIMESTAMP$ - 5 * 24 * 24 * 60)) AND ('Status' < "Closed") AND ('last updated by' <> "team1" ) AND ('last updated by' <> "team2" ) AND ... till team8

Related

How to get data month wise sqflite in Flutter?

Image for how does data look I am making an expense tracker app using flutter, I want to show the sum of expenses done by the user every month for example:
Month Amount Spended
January 2000
February 1600
Database columns:
"CREATE TABLE $TABLE_EXPENSES ("
"$COLUMN_ID INTEGER PRIMARY KEY,"
"$COLUMN_NAME TEXT,"
"$COLUMN_AMOUNT TEXT,"
"$COLUMN_UNNECESSARYEXPENSES INTEGER,"
"$COLUMN_CATEGORY TEXT,"
"$COLUMN_DATETIME TEXT"
")",
I am using sqflite to create a database and I am storing data as text. I want to retrieve expenses of every day in a month and then sum up the expenses of every day and show it in ListTile
Edit:
Query: 'SELECT * SUM(COLUMN_AMOUNT) FROM TABLE_EXPENSES WHERE COLUMN_DATETIME >= ? AND COLUMN_DATETIME <= ?'
This is the error that I am getting (for query):
E/SQLiteLog(10318): (1) near "SELECT": syntax error
E/flutter (10318): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: DatabaseException(near "SELECT": syntax error (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM expenses WHERE SELECT * SUM(COLUMN_AMOUNT) FROM TABLE_EXPENSES WHERE COLUMN_DATETIME >= 2019 AND COLUMN_DATETIME <= 1989) sql 'SELECT * FROM expenses WHERE SELECT * SUM(COLUMN_AMOUNT) FROM TABLE_EXPENSES WHERE COLUMN_DATETIME >= ? AND COLUMN_DATETIME <= ?' args [2019, 1989]}
Function which I am currently using:
Future getDataJan() async{
final db = await database;
sumJan= db.rawQuery(
'SELECT SUM(AMOUNT) FROM EXPENSES WHERE DATETIME >= ? AND DATETIME <= ?',
[2021-01-01, 2021-01-31] ).then(Sqflite.firstIntValue);
finalJan=sumJan.toString();
}
Image:
errorImage
Thanks for your replies.
You can operate with a date with format like yyyy-MM-dd HH:mm:SS and create requests to database for search entities between month.
Date format example:
DateFormat('yyyy-MM-dd HH:mm:SS').format(date)
Query example:
return database.query(
tableName,
where: 'date >= ? and date <= ?',
whereArgs: [from, to],
)
.then((data) => data.map(_fromMap).toList());
Variables in example:
from - first day of month (2020-10-01);
to - last day of month (2020-10-31);
? in where - takes values from whereArgs (first ? - from, second - to);
Note: in comments describes that you should use SQFLite tooling for creating requests and do not use raw queries (for performance reasons).
Select example
final result = await database.rawQuery(
'select * sum(COLUMN_AMOUNT) from TABLE_EXPENSES where COLUMN_DATETIME >= ? and COLUMN_DATETIME <= ?',
[from, to],
).then(Sqflite.firstIntValue);

Active record query issues in Rails 3.2

I have category model and category has many postings.
Problem: Sometimes postings are not visible under category in web even records are present in database
I investigated the query for the action in production enviroment by enabling config.log_level = :debug and restarted the
nginx passenger server. Now I can see the records under the category. I was unable to reproduce the same issue again and it occurs rarely.
Note:
I didn't change any code in the project. The same code behave differently.
Rails is 3.2.22. Nginx passenger(5.1.1)
Model are as follows
class Category < ActiveRecord::Base
has_many :postings, conditions: ['paid = ? AND start_date <= ? AND end_date >= ?', true, Date.current, Date.current]
end
class Posting < ActiveRecord::Base
searchkick
belongs_to :category
class << self
def payed
where paid: true
end
def activated
where :code => ""
end
def starts_on(date)
where "start_date <= ?", date
end
def ends_after(date)
where "end_date >= ?", date
end
def in_location(state,city)
where(stateid: state.id, cityid: city.id)
end
def not_deleted
where "active != false"
end
end
Postings controller
def index
#category = Category.find(params[:category_id])
postings = #category.postings.payed.activated.not_deleted.starts_on(Date.current).ends_after(Date.current).order(:created_at)
#postings = postings.in_location(current_state, current_city).page(params[:page])
end
From production.log, when accessing postings page /postings?category_id=25
Category Load (0.2ms) SELECT categories.* FROM categories
WHERE categories.id = 25 LIMIT 1
(0.4ms) SELECT COUNT(*) FROM postings WHERE
postings.category_id = 25 AND postings.paid = 1 AND
postings.code = '' AND postings.stateid = 44 AND
postings.cityid = 14823 AND (active != false) AND (paid = 1 AND
listing_start_date <= '2017-03-13' AND listing_end_date >=
'2017-03-13') AND (listing_start_date <= '2017-03-13') AND
(listing_end_date >= '2017-03-13')
CACHE (0. SELECT COUNT(*) FROM postings WHERE
postings.category_id = 25 AND postings.paid = 1 AND
postings.code = '' AND postings.stateid = 44 AND
postings.cityid = 14823 AND (active != false) AND (paid = 1 AND
listing_start_date <= '2017-03-13' AND listing_end_date >=
'2017-03-13') AND (listing_start_date <= '2017-03-13') AND
(listing_end_date >= '2017-03-13')
Posting Load (0.4ms) SELECT postings.* FROM postings WHERE
postings.category_id = 25 AND postings.paid = 1 AND
postings.code = '' AND postings.stateid = 44 AND
postings.cityid = 14823 AND (active != false) AND (paid = 1 AND
listing_start_date <= '2017-03-13' AND listing_end_date >=
'2017-03-13') AND (listing_start_date <= '2017-03-13') AND
(listing_end_date >= '2017-03-13') ORDER BY created_at LIMIT 10 OFFSET
0
The above set of queries did not pick any records; and after enabling debug mode and restart/touch the nginx server the same query fetched available records
Is the problem caused by active record query/ Nginx/ cache?
Please help me to resolve this issue.
Fixed the problem using Proc for association condition like
has_many :postings, conditions: proc { "payed = 1 AND start_date <= '#{Date.current.to_s(:db)}' AND end_date >= '#{Date.current.to_s(:db)}'"}
If you would have done association with dynamic condition like has_many :postings, conditions: ['paid = ? AND start_date <= ? AND end_date >= ?', true, Date.current, Date.current], there will be cases when the results you’ll get are not expected since the condition will have the day you started the Rails application and Date.current won’t be called again.
Thanks to Jose M.Gilgado. Reference: http://josemdev.com/articles/dynamic-conditions-associations-rails-3/

How do I create local variable to track an ID that will output whether it was first payment

Been working on this project for a week and feel I'm getting closer. Created a PL/SQL block that will output a donor's specific pledge, number of payments, pay date and pay amount I've got most of it done and it compiles and produces desired output with exception of handling whether or not it was the first payment on the corresponding row. How can i create a variable to track this and then test it within the block and not bugger up what I've go already. Here is a sample of the output I get now and my PLSQL code. Thanks!
Pledge ID: 106 Pledge Amount: $75 Monthly Payment: $0 Pay Date:12-OCT-12Amount Paid: $75
Pledge ID: 109 Pledge Amount: $360 Monthly Payment: $12 Pay Date: 01-FEB-13 Amount Paid: $30
Pledge ID: 109 Pledge Amount: $360 Monthly Payment: $12 Pay Date: 01-MAR-13 Amount Paid: $30
As you can see 'First Payment' should be displayed on the first two rows.
My Code:
DECLARE
pledge_id DD_PLEDGE.idpledge%TYPE;
pledge_amt DD_PLEDGE.pledgeamt%TYPE;
pay_months DD_PLEDGE.paymonths%TYPE;
pay_date DD_PAYMENT.paydate%TYPE;
pay_amt DD_PAYMENT.payamt%TYPE;
donor_id DD_PLEDGE.iddonor%TYPE;
CURSOR cur_pledges IS
SELECT pl.idpledge, pl.pledgeamt, pl.paymonths, pay.paydate,
pay.payamt, pl.iddonor FROM DD_PLEDGE pl JOIN DD_PAYMENT pay ON
pl.idpledge = pay.idpledge
WHERE pl.iddonor = 301
ORDER BY pl.idpledge, pay.paydate;
BEGIN
OPEN cur_pledges;
LOOP
FETCH cur_pledges INTO pledge_id, pledge_amt, pay_months, pay_date,
pay_amt, donor_id;
--possible test here for first payment
DBMS_OUTPUT.PUT_LINE('Pledge ID: ' || pledge_id || ' Pledge Amount: $'
|| pledge_amt || ' Monthly Payment: $' || pay_months
|| ' Pay Date: ' || pay_date || ' Amount Paid: $' || pay_amt);
EXIT WHEN cur_pledges%NOTFOUND;
END LOOP;
CLOSE cur_pledges;
END;
If I am understanding your question correctly.
You are trying to find out first payment done by a donorid .
Then Use %ROWCOUNT in a cursor to find out how many rows are there for that donor.if more than one row then it is not his first payment else first payment
DECLARE
pledge_id DD_PLEDGE.idpledge%TYPE;
pledge_amt DD_PLEDGE.pledgeamt%TYPE;
pay_months DD_PLEDGE.paymonths%TYPE;
pay_date DD_PLEDGE.paydate%TYPE;
pay_amt DD_PLEDGE.payamt%TYPE;
donor_id DD_PLEDGE.iddonor%TYPE;
First_pay_flag varchar2(10); --Just set a flag
CURSOR cur_pledges IS
SELECT pl.idpledge, pl.pledgeamt, pl.paymonths, pl.paydate,payamt,iddonor
from DD_PLEDGE pl WHERE pl.iddonor = 007
ORDER BY pl.idpledge, pl.paydate;
BEGIN
OPEN cur_pledges;
LOOP
FETCH cur_pledges INTO pledge_id, pledge_amt, pay_months, pay_date,pay_amt, donor_id;
DBMS_OUTPUT.PUT_LINE('Pledge ID: ' || pledge_id || ' Pledge Amount: $'
|| pledge_amt || ' Monthly Payment: $' || pay_months
|| ' Pay Date: ' || pay_date || ' Amount Paid: $' || pay_amt);
IF CUR_PLEDGES%ROWCOUNT = 1 THEN
--DBMS_OUTPUT.PUT_LINE('First payment');
First_pay_flag := 'YES';
Else
-- DBMS_OUTPUT.PUT_LINE('Not the first payment.');
First_pay_flag :='NO';
END IF;
EXIT WHEN cur_pledges%NOTFOUND;
END LOOP;
CLOSE cur_pledges;
DBMS_OUTPUT.PUT_LINE(chr(10)||chr(13) || 'Is this a first payment ? ' || First_pay_flag );
END;
P.S. I have created single table. Change them

Search the database to get date between

I have this select statement:
SELECT *
FROM Room
LEFT JOIN booking ON (Room.RoomId = booking.RoomId)
WHERE booking.Roomid is null
AND GETDATE() BETWEEN bookin.checkindate '" + TxtCheckIn.Text + "'
AND booking.checkoutdate '" + TxtCheckOut.Text + "'" + "
ORDER BY Room.RoomType
I want to check in the booking table if the date matches the checkin and checkout dates selected by users. If it doesn't match, the query should show all rooms in the room table (even if it is in the booking table), provided that they have different dates.
You need to determine whether any rows match the condition on the date. To do this, the following query moves the date condition into the on clause. Then it uses the window function count() to count the number of matches. If there are none, then all rows are returned. Otherwise, only matches are returned.
select t.*
from (SELECT *, count(booking.RoomId) over () as numMatches
FROM Room LEFT JOIN
booking
ON Room.RoomId = booking.RoomId and
GETDATE() BETWEEN booking.checkindate '" + TxtCheckIn.Text + "' and
booking.checkoutdate '" + TxtCheckOut.Text + "'" + "
) t
where numMatches > 0 and RoomId is not null or numMatches = 0
ORDER BY Room.RoomType

Problems with Recordset Filter

I'm having trouble with a filter on an ADO Recordset in legacy ASP Classic code, and I'm trying to understand if what I'm trying to do is not supported, or if I'm just doing it wrong.
I have a recordset of Items, and they have a Status of 1 (active) or 0 (inactive), and an optional End_Date. In my administrative user interface, I have a control to show all items or only those that should be displayed to end-users: Status = 1 AND ( End_Date is null OR End_Date > Date() )
To implement that logic, I tried:
rs.Filter = "Status = 1 AND ( End_Date = null OR End_Date > #" & Date() & "# )"
but I get
ADODB.Recordset (0x800A0BB9)
Unknown runtime error
After much fooling around, it seems that ADO doesn't like the grouping parens around the End_Date conditions in combination with the AND condition. If I take the parens out, this works:
rs.Filter = "Status = 1 AND End_Date = null OR End_Date > #" & Date() & "#"
But that's just an accident -- it looks like the filter conditions are evaluated in order, and so I get the results I want. If I change the AND to OR, the parens work:
rs.Filter = "Status = 1 OR ( End_Date = null OR End_Date > #" & Date() & "# )"
But of course that logic is wrong -- it shows Active but expired items.
Strangely, if I move the conditions around, it breaks again:
rs.Filter = "End_Date = null OR Status = 1 AND End_Date > #" & Date() & "# "
crashes with the same ADODB error.
I can't seem to predict what will and won't work, and the docs I've read are very sketchy on the syntax expected (it's not pure T-SQL!), the limitations, etc. and all the examples I've seen have at most two conditions. I don't think my conditions are all that complex. Can anyone tell me if what I'm trying to do is supported, if there's a better way to do it, or point me to comprehensive docs and samples that match this kind of logic?
Thanks!
ADO Recordset Object Filter Property:
There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this:
(LastName = 'Smith' OR LastName =
'Jones') AND FirstName = 'John'
Instead, you would construct this
filter as:
(LastName = 'Smith' AND FirstName =
'John') OR
(LastName = 'Jones' AND FirstName =
'John')
So you would have to construct your filter like this:
rs.Filter = "( Status = 1 AND End_Date = null ) OR ( Status = 1 AND End_Date > #" & Date() & "# )"
I know that you are working with legacy code and probably other things are working, but how do you open the recordset in this specific page? Are you using some constant defined in adovbs.inc?
For example:
rs.Open "SELECT * FROM table1", db, adOpenStatic, adLockPessimistic
What happens when you try this...
Dim strToday
strToday = Now()
rs.Filter = "Status=1 AND (End_Date = null OR End_Date > """ & strToday & """)"

Resources