How can I sum two group by outcomes in MYSQL
I am trying to obtain the following result: Imagine I have an object table in the following format Name Object id Status A A. . On A B. . Off A C. . Other B D. . On B E.…
I am trying to obtain the following result: Imagine I have an object table in the following format Name Object id Status A A. . On A B. . Off A C. . Other B D. . On B E.…
Given a table called budgets containing a rate and a time_span I want to generate a monthly daily rate for each day. The time_span must have a start date but can be open ended ["2023-06-02 00:00:00+00",). For example given the…
If I have dates Column and i want to select dates of monday and sunday only from past 1 year, how can i do it with effective code in SQL I tried to select manually the dates but its very…
I'm working with PostgreSQL and I want to enforce a particular column to be unique. But this table has some legacy data in which duplicate of the column are there and they have to be retained unmodified. So when I…
I am still at beginner level on SQL programming so please bear in mind ... My database is similar to the below: +---------------------+------------+--------+------+--+ | Date | FileName | Type | File | | +---------------------+------------+--------+------+--+ | 2023-06-15 08:03:04 | InputParam |…
I'd like to assign type timestamp without timezone to all columns name created_at at my database scheme. I'm trying to run this query: DO $$ DECLARE table_name text; BEGIN FOR table_name IN SELECT table_name FROM information_schema.columns WHERE column_name = 'created_at'…
I have a postgreSQL function which takes a text array as one of the input parameters: CREATE OR REPLACE FUNCTION report.fn_get_metrics( from_date timestamp without time zone, to_date timestamp without time zone, location_ids text[]) RETURNS TABLE(demand_new_count bigint) LANGUAGE 'plpgsql' COST 100…
I'm building a language learning platform, here are some tables: create table users ( id bigserial primary key, ... ) create table users_languages ( id bigserial primary key, user_id bigint not null constraint users_languages_user_id_foreign references users, level varchar(255) not null,…
I have a mysql table with the following structure: Assign Pri Sec Ter Qua 21 Tom Mark Sally Tammy 60 Sally Ace Tom Mark 170 Mark Sally Ace Tammy 220 Ace Tammy Tom Sally 17 Tammy Sally Mark Ace 439…
I have values like below in dealer_price(type string) field: | dealer_price | | -------- | | 1000.00| | 5000.00| | Contact for pricing| | 10000.00| I have queries something like below to perform arithmetic operation: select (dealer_price + 10) AS…