I have a following query for DB2 database: BEGIN DECLARE NUMBER_OF_ROWS INT; DECLARE ITER_INDX_1 INT; DECLARE ITER_INDX_2 INT; SET ITER_INDX_1 = 0; SET …
Tag: sql
SQL: Update every entry with value from another entry that share same column value
I have the following table trn_ReceiptLog I am wondering if it’s possible to update amount of entry #1 to have same as entry #2 IF amount of entry #1 is 0? I have over 5000 of these entries that …
Joining two rows into one rows (different column) in oracle
I have table with values like this ID |Name |Balance |Type |ProductName 1 Abdol 10000 1 RAID100 2 HIVE 5000000 2 RAID100 3 Ade 20000 …
Parse xmltype into table after pivot xml
i have return XMLTYPE after pivot xml that looks like Ukraine 12345
select sum where condition is true and count > 3
I have two tables. FootballPlayers with columns Id_footballplayer, Last_Name, Fisrt_Name, Age Transfers with columns Id_transfer, Name_club, price, date, acceptance (yes or no), code_footballplayer How can I write a SQL query to select the last names of the players and the sum of the successful transfers carr…
How to JOIN postmeta table and get the posts before the date of custom field using SQL
I’d like to combine wp_posts table and wp_postmeta table and get the posts before the date of custom field. Code with only wp_posts table is below and it works fine I want to add “postmeta table” to “post table” and get only posts before the date of custom field if it is “W…
use concat or replace for values in the middle SQL / Postgresql
how to use concat for values in the middle, I have the following data and I want to change it to be like this I tried with a query like this, but the results did not match what I expected this is the result of my query Answer You can simply use
SQLDateTime OverFlow with Correct DateTime Format
below is my code snippet where I insert a DateTime value to SQL database and encountered the following error: System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. May I know if there is a format to be used? when converting the value of r…
Selecting default row if no rows return with join condition values from other tables
I have two tables ORDERS and RATE: and I would like to get the costs of all the orders in table ORDERS, given that a default rate of 10 is used for those orders which do not have rates in the RATE table for the corresponding ids, and if an id is available in the RATE table, but no rate
SQL Get Parent when child is column is 0
I have two tables below. Data: Using joins I have got the information from both the tables which have needed, but in a new case I need to extract the Address like if the IsNetwork = 0 then Address should of it’s the parent. Following is the query of join This is the output of that query: I want the