Skip to content
Advertisement

Delete rows depending on values from another table

How to delete rows from my customer table depending on values from another table, let’s say orders? If the customer has no active orders they should be able to be deleted from the DB along with their rows (done using CASCADE). However, if they have any active orders at all, they can’t be deleted. I thought about a PLPGSQL function,

SELECT data grouped by WEEK in SQL

I have a working query (ORACLE SQL) that gives me gallons grouped by store number, with gallons summed by type and a percentage column as well. Each store number has a different conversion date from which I sum up the data – I now need to also sum it up by week, with Sunday being the first day of each

Group rows based on column values in SQL / BigQuery

Is it possible to “group” rows within BigQuery/SQL depending on column values? Let’s say I want to assign a string/id for all rows between stream_start_init and stream_start and then do the same for the rows between stream_resume and the last stream_ad. The amount of stream_ad event can differ hence I can’t use a RANK() or ROW() to group them be

insert values in the last column for my table from another table

Hi I’m trying to insert values in the last column for my table from another table but am getting error ERROR: null value in column “name” violates not-null constraint DETAIL: Failing row contains (ddf1caf0-26c2-49e1-8a73-64227eae1f50, null, null, null, null, null, 2532). Answer I suspect that you want to update the column subsystem of the table software_instances with values of the column

Advertisement