Selecting the most recent date from a table in PeopleSoft using Peoplesoft Query (Max() doesn't work) - peoplesoft

I am building a query in people soft using Peoplesoft query manager.
I am trying to pull the most recent date from the date column. I have tried using max() as an expression, however, the query doesn't pull any records.
I have checked with another co-worker and they have never been able to pull records using max().
Is there any other way or workaround to pull the most recent record?

So I figured out why no results were returned when using Max in a subquery. It was more from a lack of understanding PeopleSoft and SQL since I am relatively new to it. When I was setting the date column in the subquery as max for the aggregate to be used as criteria to compare to the date column in the main query I didn't make any criteria in the subquery. This meant that the subquery would go through all dates for all employees except for the employee that I was specifying in a prompt and returning a value that didn't match any of the dates for the employee in the main query and returning no one. This was fixed by setting a criteria in the subquery that the employee ID that had to be searched in the subquery matched the one that was typed into the prompt in the main query

Use effective date for doing such searches while using PSQuery.

Use Effective date in order to get the most recent date, max may not work properly in PeopleSoft. Query should be effective dated

PS Query has built in filters for EFFDT tables. When you add a criteria on the EFFDT field, there are some additional drop down choices on the "condition type" field like 'Eff Date <' and 'Eff Date <=', etc. Usually, when you create a query for an Effective dated table, PS Query will automatically add the subquery based on the 'Eff Date <=' condition type.

Related

PeopleSoft Query Manager - 'count' function

I'm using the current version of PeopleSoft and I'm using their Query manager. I've built a query that looks at the job table and a customized version of the job table (so I can see future hires). In order to do this I've created a union. Everything works fine, except now I want to do a count of the job codes.
When I put in a count, I get an error. I don't know how to get it to work properly. I also don't really know how to using the 'having' tab.
I've attached some screenshots, including the SQL code.
SQL:
Having tab
You have a criteria in your query:
AND COUNT(*) = A.JOBCODE
Your job codes are string values that uniquely identify a job. It will never be equal to a count.
If you remove that criteria, your query will work:
The bigger issue is, what do you want to count? If your query was simply:
SELECT DEPTID, JOBCODE, COUNT(*)
This will give the count of employees in this department and job code. In your description, you said that you wanted the count of job codes. But each row has JOBCODE on it. The count of job codes on the row is one. What do you really want? The count of job codes in the database? The count of job codes in the result set?
If you want to get anything other than the count of rows within the group, you are not able to put that logic in PeopleSoft Query. You will need to create a view in AppDesigner and then you can add that to the query.

CosmosDB: DISTINCT for only one Column

I have the following query:
SELECT DISTINCT c.deviceId, c._ts FROM c
ORDER BY c._ts DESC
I would like to receive only one pair (c.deviceId, c._ts) per deviceId, but because the c._ts value is distinct for all entries, I am getting all the value-pairs for all deviceIds, with other words my whole DB.
I have tried to use Question: Distinct for only one value as a guide, but I see that CosmosDB does not support GROUP BY.
Is there a way to do this in cosmosDB?
Though it's a common requirement i think,i can't implement it on my side as same as you. The distinct keyword can't work on one single column cross whole query result.
Group by feature is currently in active development for a long period,based on the latest comment in this voice,it is coming soon.
If your need is urgent ,as workaround, you could follow this case to use documentdb-lumenize package which supports Aggregate Functions.

Last Function in Query

So I currently have a database that keeps tracks of projects, project updates, and the update dates. I have a form that with a subform that displays the project name and the most recent update made to said project. It was brought to my attention however, that the most recent update to a project does not display correctly. Ex: shows the update date of 4/6/2017 but the actual update text is from 3/16/2017.
Doing some spot research, I then learned that Access does not store records in any particular order, and that the Last function does not actually give you the last record.
I am currently scouring google to find a solution but to no avail as of yet and have turned here in hopes of a solution or idea. Thank you for any insight you can provide in advance!
Other details:
tblProjects has fields
ID
Owner
Category_ID
Project_Name
Description
Resolution_Date
Priority
Resolution_Category_ID
tblUpdates has these fields:
ID
Project_ID
Update_Date
Update
there is no built-in Last function that I am aware of in Access or VBA, where exactly are you seeing that used?
if your sub-form is bound directly to tblUpdates, then you ought to be able to just sort the sub-form in descending order based on either ID or Update_date.
if you have query joining the two tables, and are only trying to get a single row returned from tblUpdates, then this would do that, assuming the ID column in tblUpdates is an autonumber. if not, just replace ORDER BY ID with ORDER BY Update_Date Desc
SELECT a.*,
(SELECT TOP 1 Update FROM tblUpdates b WHERE a.ID = b.PROJECT_ID ORDER BY ID DESC ) AS last_update
FROM tblProjects AS a;

Obtain record from sqlite by most recent date

I have an Objective-C app that utilizes CoreData and the backing store is a sqlite database.
I'm trying to formulate a query for the FMDatabase to access the most recent record according to the MediaDate.
Here is the table I'm querying, called MediaAccy which has a MediaDate field which is of type timestamp (pictured here)
Here's a query that simply ORDERS the MediaDate field. Notice the ZMEDIADATE field has 2 identical timestamp values, and notice the order of the guids.
According to this query, the most recent record has guid 6BBF7...
Now, notice THIS query, where I ask for the record with the MAX date from the given set of records above, and notice the result is for guid 2D8AC... which according to the previous query, that ordered that same data by date, is the 2nd to most recent, not the most recent record.
Will the real most recent record please stand up!
According to sqlite's documentation for the max() function...
The max() aggregate function returns the maximum value of all values in the group. The maximum value is the value that would be returned last in an ORDER BY on the same column
But according to my results, this isn't what in fact is happening.
After some more research, it appears that timestamp is only to second precision, and the ORDER BY clause documentation says...
The order in which two rows for which all ORDER BY expressions evaluate to equal values are returned is undefined.
So I guess I'm going to have to rethink this whole thing.

Getting recent N items from DynamoDB

I just started figuring out DynamoDB.
I have a simple table has date attribute(ex. 20160101) as HASH and created_at attribute(ex. 20160101185332) as RANGE.
I'd like to get latest N items from the table.
First, SCAN command does not have ScanIndexForward option. I think it's not possible with SCAN.
Next, QUERY command. It seems to be work if I repeat QUERY command several times to get enough number of items(cuz, I don't know how many items have same key value). - for example, I can query using today first and repeat for the day before if the result does not give enough items.
How can I do the job more efficiently? Or, can I query without KEY value?
as you described your table, you cant do it more efficiently, and you cant query dynamodb without KEY(hash) value
look at the answer here:
dynamodb get earliest inserted distinct values from a table

Resources