I have the following two SQL tables dog and toy: dog id gender 1 2 2 2 3 2 4 1 toy toy_id dog_id 1 1 1 2 2 1 2 2 We want to find out how many female dogs have a certain 0 toys, 1 toy, 2 toys… A value of 2 in the gender column indicates the
How to remove and carry forward month prior when running balance decreases?
I have the following data: client_id balance_month balance 100000000 September 1,2021 12:00 AM $7000 100000000 August 1,2021 12:00 AM $7000 100000000 July 1,2021 12:00 AM $6000 100000000 June 1,2021 12:00 AM $3000 100000000 May 1,2021 12:00 AM $20000 100000000 April 1,2021 12:00 AM $1000 100000000 March 1,202…
SQL query to select all tuples that do not have a specific attribute at all
I have a table (shown below) that maps users to the fruits that they like. This table is a result of a a complicated SELECT statement, and now I am left with specifying the WHERE condition. I would like to select all users that do not like the fruit “Orange” at all. U.id F.fruit 1 Apple 1 Orange 1…
BigQuery SQL reshape four columns into one column with name of column as value
I currently have a table that looks like: Is it possible to reshape my data into: Where the name of the column equal to 1 becomes the value of code in the new reshaped dataset. I have already presorted the dataset such that there will be no case where more than one column is equal to 1. Answer Consider below
Can I connect a openCart project with mobile app? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question my English doesn’t well, I am sorry I have a open Cart project this project have own dat…
Kubernetes Whitelist Alternative SQL Server
We have a SQL Server hosted on a cloud VPS and a kubernetes cluster hosted on Digital Ocean. I am using their kubernetes offering. Our server the SQL Server sits on, has firewall rules to only allow whitelist IPs to connect to the SQL Server. So currently we add the IPs to each of the kubernetes nodes so they…
Efficient syntax to update 5K rows in BQ table
I’m trying to update ~5K rows in bq using python client. Here is my current try: and How can I map the account id list to a string as follows which seems more efficient(?) UPDATE mytable SET somefield=( CASE WHEN (id=100) THEN ‘some value removed’ WHEN (id=101) THEN ‘some value removed…
How to make revenue $0 for months prior to decrease in SQL?
I have the following data: client_id balance_month balance 100000000 September 1,2021 12:00 AM $400 100000000 August 1,2021 12:00 AM $100 100000000 July 1,2021 12:00 AM $200 100000000 June 1,2021 12:00 AM $300 200000000 September 1,2021 12:00 AM $99 200000000 August 1,2021 12:00 AM $100 200000000 July 1,2021 …
How do I reset a MySQL column in a table every year?
I have a column named lv_casual in a table called tbl_employees. I need to reset the column to 0 at a specific date every year. Answer You can use MySQL event schedule. Providing an example below. You have to enable the schedular first Then create the event Check MySQL document for creating event
MySQL Joining multiple tables with where clause result is too slow
Let’s say I have the following structure of tables; and I want a result of; So I used the following query; I still have other tables that are connected to table1. The problem is the result is too slow even though there are only three results. I’m not that good at databases maybe I’m doing it…