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 …
Tag: sql
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…
Data Architecture Question – Storing Daily Snapshot of Employee Master Data
I’m trying to store daily snapshot of Employee data for FTE analysis project – analytics on how many FTE in various positions any given day. I can call a REST API, which will give me data for all the active and terminated employees as of API call time. Is it prudent to call this API every single d…
How to retrieve data from two MySQL tables with multiple associations
I got these two tables where one table is having multiple foreign keys to the second table. Table rankings Table item One ranking record may have multiple association to item table using first_item_id, second_item_id, third_item_id or forth_item_id fields. I want to retrieve ranking records with the correspon…
Error Referencing Sub Query in Group By on Main Select statement in T-SQL
I am trying to run the following T-SQL code Example: Order table Item table Result: I need to be able to count the number of items for that order per month and year however, I am getting this error Column ‘Order Reference’ is invalid in the select list because it is not contained in either an aggr…
How to schedule biweekly SSRS subscription on 2017 report server
I would like my report to be sent biweekly on a Monday. Right now, I created two different subscriptions that sends the report on every 2nd and 4th week. I am not sure it would be accurate considering, I would like the send the report Monday after Pay period ends. What’s a best way to approach to this? …
SQL UPDATE column with self referenced id from another column
I want to update the ParentId of each row that is not null With the Id from the row that has a TemplateId Matching ParentId Id ParentId TemplateID 1001 NULL 86 1002 86 41 1003 43 44 1004 NULL 43 1005 44 73 Desired results: Id ParentId TemplateID 1001 NULL 86 1002 1001 41 1003 1004 44 1004 NULL 43
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…