Split one SQL column into multiple based on condition – Mysql
I need to split one column in two based on some condition. Here is an example of table: id | title ---------- 1 | one 2 | two 3 | three 4 | four So, I'd like to have a…
I need to split one column in two based on some condition. Here is an example of table: id | title ---------- 1 | one 2 | two 3 | three 4 | four So, I'd like to have a…
I have a postgresql table contains a list of email addresses. The table has three columns, Email, EmailServer (e.g., gmail.com, outlook.com, msn.com, and yahoo.com.ca etc.), and Valid (boolean). Now, I want to group those emails by EmailServer and then update…
This is team table : +----+-------+--------+-------+ | id | alias | pwd | score | +----+-------+--------+-------+ | 1 | login | mdp | 5 | | 2 | azert | qsdfgh | 50 | | 3 | test | test…
I want to count certain values in all tables of a schema that contain a column that can contain those values. Was hoping to use a LATERAL join to loop over all tables, but I'm running into issues: select fully_qualified_table_name,…
So, next problem :'), I have the following query that @MatBailie provided to me here (thanks again!): SELECT taskname, employee, SUM( DATEDIFF( LEAST( enddate, '2023-12-31'), GREATEST(startdate, '2023-01-01') ) +1 ) AS total_days, FROM schedule WHERE startDate <= '2023-12-31' AND endDate…
CREATE VIEW A1 AS SELECT client_ID , COUNT(dog_id) FROM test_clients GROUP BY client_ID HAVING COUNT(dog_id)=2; CREATE VIEW A2 AS SELECT filial , COUNT(A1.client_ID) FROM A1 JOIN test_clients USING (client_ID) GROUP BY filial HAVING COUNT(A1.client_ID)>10; SELECT COUNT(filial) FROM A2; As far…
I want to display some statistics to users that entered a command and I'm using to different SQL queries for that. The first one: SELECT COUNT(*) FROM guild_finished_giveaways WHERE guild_id = {} AND winner_id LIKE '%750718563651944518%' I want to get…
I have a table name ar for column operation in it I can allow only specific values ('C', 'R', 'RE', 'M', 'P'). I have added a check constraint for it. Requirement: I need to insert 1 million records in the…
I have the same issue listed in this SO question, but I have tried the solution and I am getting a SQL error 1288- I'm thinking I am poorly translating SQL server to SQL or this method has been deprecated.…
I'm using PostgreSQL and I have a table with the following columns: id, distance, and length. I want to order the table by distance and create a new column called cum_length using a window function. I also want to filter…