I have two tables one is SifraArtikla The second table ArtikalUsluge extend the SifraArtikla ID I need to get from PuniNaziv column ‘PW60’ if ArtikalID is 1 else if ID is 2 ‘PW120’ else if ID is 3 ‘pw250’ I tried with if else statment but it didn’t work. Can anyone gi…
Aggregate time from 15-minute interval to single hour in SQL
I have below table structure in SQL Server: Is there a way to group above data into one hour interval instead of 15 minute interval? It has to be based on start and end columns. Thanks, Answer Maybe something like the following using datepart?
SQL Server: Convert YYYYMMDD-HHMM and YYYYMMDD to mm/dd/yyyy hh:mm
I am trying to convert the time format from YYYYMMDD-HHMM and YYYYMMDD to mm/dd/yyyy hh:mm. My issue is that the data is not consistent. Below is some exemple: I tried to use: but the issue is that some data does not have time. Answer You can do it like this:
Add new column with Boolean in PL/SQL
I’m learning PL/SQL right now and I have a doubt. I have created the following table called tbProducts: And I have inserted some values so the table is like this: Now what I’m looking for is a boolean variable that can be called bUpdate that returns FALSE if today’s date (26-AUG-2021) is gre…
Postgres transpose a row
I have a table which looks like the following :- I want to transpose it to the following form, in Postgres: I know I’m supposed to use the pivot operation to do this, but I can’t figure out the right syntax to get this done. Any help to get this done will be appreciated. Answer That would simply b…
SQL Summing columns based on date key
I have a dataset as given in the link, DataSet I want to segregate the column “order_item_unit_status” as separate column and bring respective transaction amount for the same. Desired output is given below. Objective is to consolidate the txn_amt into respective categories and group them based on …
Stored procedure expects parameter ‘Incorrect syntax near ‘:’.’
I have the following stored procedure in SQL Server: CREATE PROCEDURE [PROC_SET_BRN_RPT_STSTC] @I_RPT_I varchar(max), @I_MSTR_TBL varchar(max) AS BEGIN DECLARE @VD_PSTG_D …
Combine like rows based on substring of one column?
I have a table of parts that looks like this: Part Part Num Thing1 Thing2 Thing3 Thing4 Door 10105322 abc abc Door 10105323 abc abc Door 10105324 abc abc Door 84625111 abc abc abc Door 84625118 abc abc abc Door 84625185 abc abc abc Door 56897101 abc abc The part number is always 8 characters. For many parts, …
How to use pg_dump correctly in order to do a database migration?
Hey everyone I am fairly new to doing a pg_dump in Postgre sql. I have logged into the server and am running as postgres user. I try to run the pg_dump in order to do a database migration but I keep getting a “Permission Denied” prompt. I believe that I have the highest permissions and should be a…
Having weird exception using MAX(CASE WHEN) in query: DB2.iSeries.iDB2DCFunctionErrorException: ‘An unexpected exception occurred
I have the following query to put some data from rows in columns: But when I try to run it in the following code: I get this exception: “IBM.Data.DB2.iSeries.iDB2DCFunctionErrorException: ‘An unexpected exception occurred. Type: System.AccessViolationException, Message: Attempted to read or write …