Skip to content

Tag: sql

One Table Update

I want to update Price where PriceGroup = ‘PG1’ and Price is null, with the Price from the same ID but the PriceGroup is PG2. I have tried a few solution here but couldn’t find any with Where statement. PriceTable: Result will be: Answer Something like this? Tried with this data and this is …

How to get columns which are not in GROUP BY?

I have a Postgresql database where I have these two tables. shipping_method shipping_details: id shipping_method_id estimated_time_min estimated_time_max price 2 1 02:00:00 04:00:00 230 3 2 00:03:00 01:00:00 500 4 1 02:00:00 04:00:00 1230 5 1 02:00:00 04:00:00 850 6 2 01:00:00 02:00:00 1785 My goal is to fetc…

Returning Json string from oracle procedure

I need to have a stored procedure in PL/SQL that return a string containing a json object. This object must be a list of object representing rows a table. For example I have the table MY_TABLE(ID, TB_VALUE) The output must be : My stored procedure looks like that : What’s the best way to achieve this ? …

MariaDB, How to copy existing records using insert?

I have a lot of existing records which I want to copy using an INSERT, for example if I have a query: The common key is biDataset, the primary key in this table is biPK which is auto incremented on each insert. Here is the table structure: What I want to do is copy all the records that exist where

Calculate expiry date 3 months from now on MYSQL

So I have been given just the expiry dates for my loyalty cards, I need the query to display all the customers whose card will expire 3 months from the current systems date not hardcoded. Lets say todays 2021-09-30, and the card expiry date for customer1 is 2021-12-12 and the customer2 is 2021-10-18. SO the q…