I’m looking to sort the rows based on a variable. I’m pulling my hair out trying to wrap my head around this kind of trigger. I’ve only ever written triggers that gets some values from other tables. …
Tag: sql
In Peoplesoft 8.5X Query Manager, Is there a way to default EMPID in filter criteria based on employee sign in?
I want to dynamically create a filter criteria in PS query manager which automatically picks EMPID value based on employee sign in ID. Is it feasible in Peoplesoft 8.5X ? I am a beginner to Peoplesoft query creation. I have not tried anything yet. SELECT A.EMPLID FROM PS_JOB A WHERE A.EMPLID = ‘XXXXR…
Correct json formatting in ms sql server
I have the following SQL table I wrote this code to format result as JSON, but can’t get it in the desired format. If i name all product columns as name then sql returns an error Use different names and aliases for each column in SELECT list. Sql code: Current output: Desired output: Answer You may try …
How to increment date using previous value from same column and skip weekend date?
I have tried to increment date based on other date column and skip weekend date. I know how to check weekend and how to skip date but I want to result as look like below EX. If I will input date in one column like then I want result in new column like NOTE: don’t skip any row from input
Categorize datetime value to shifts where shift ends on the next day
I have a MySQL query for example: My table only have qty and filedatetime columns. Based on this query is it possible to query out the following conditions: if filedatetime is filedatetime >= ‘2019-08-01 06:30:00’ and filedatetime < ‘2019-08-01 18:30:00’ then assign value ‘…
the select convert function not working ! Return the syntax error?
I am using DBeaver. Here is my piece of code: This is the error: [42601]: ERROR: syntax error at or near “,” Because the data is too specific to extend of hour and minute so I want to change it. Not extract details out of it. Please help or at least give me another solution. Answer The CONVERT fun…
How to use order by after group by sql
I have a table like this: and I need to group by and order on positionNr. I tried with this query: But I obtain something like this: But what I want is a result like this: Please can you help to understand where is the problem on the query? Answer Based on your expected result, it seems that: 1- You
Replace comma separated list stored in database
I have a table with a field named Schedule with data type varchar(20) that currently holds a comma separated list of up to six (6) two (2) character schedule codes. Theses codes range from [a1-a9]-[g1-…
Find a list of all suppliers with orders from more than 615 different customers. Should return supplier name and customer count
Tables: Supplier: S_SUPPKEY, S_NAME Customer : C_CUSTKEY, C_NAME Orders : O_ORDERKEY, O_CUSTKEY Lineitem : L_ORDERKEY, L_SUPPKEY In the Lineitem table, there are many columns with the same ORDERKEY, …
Return number of rows since last occurrence
I want to find the number of reports a user has submitted since a user last received a personalized response. The column response_type has 3 possible values: “No Response,” “Templated Response,” and “…