I’m currently trying to link up database names with image filenames, and I’ve been successful in doing this so far. However, when I try to put these names on-top of an image, it only takes the last …
Tag: sql
Selecting new distinct values over time (ORACLE SQL)
I want to select new distinct values and track them over time. I have a table where each row represents a score awarded to a particular person. – timestamp (when the score was awarded) – name (which person received the score) – score (what score the person received) I want the result to look…
Exclude blank columns from XML
I am trying to get Table Rows to XMLs. I am able to do it in the following way and the only issue I have is that it also generates XML tags for blank columns. create table test_niks_01(x int, y …
Is it possible to create an ENUM of smallints in postgres 11.x?
I’d like to create an enum TYPE to constrain a pl/pgsql function to accept an argument that’s 1, 2, or 3. Enum types seemed like the way to go about this. I’ve tried creating my enum as below: Answer According to the PostgreSQL documentation, an ENUM type is always going to be a fixed value:…
Sql query to find the job and grade according to particular column conditions
I have created a query – Now I want the output such that ,according to the value of legal_emp and SAL_hour I will have to calculate grade and job from another table in the same query. Something like – How can i achieve this in a single query ? Answer sounds like CASE WHEN should be able to fix thi…
sql – how to count rows in sub-query according main query items
I’m trying to get a list like this: StockPart.title | qtyAvailable qtyAvailable is the SUM() of stockItems rows where stock_items.stock_part_id = stock_parts.id (main query) By using something like …
Prioritize one column over another
DB-Fiddle In the table above I have different campaigns with their corresponding quantities. The quantities are filled in different columns. Now, I want to get the latest available quantity for each campaign based on the following hierarchy: The result should look like this: What query do I need to achieve th…
SQL – Calculate number of occurrences of previous day?
I want to calculate the number of people who also had occurrence the previous day on a daily basis, but I’m not sure how to do this? Sample Table: | ID | Date | +—-+———–+ | 1 | 1/10/…
How to save data after using With Clause?
I want to save the data I have after With Clause. Maybe saving into TEMP table or some other data set. WITH TASKLIST AS (SELECT * FROM IC_V_NEWSKUSTASKLIST WHERE MSTID IS NULL), RESULTS AS (SELECT *…
Find first occurance within a group of groups
I have a table with 5 columns. I want to find the % received of the last date and first occurance of date_rec. Output required: Answer In R, we can do slice after grouping by ‘Country’, ‘Flow’ The above assumes that the ‘Date’ are ordered (in the OP’s example it is al…