I have a simple Azure function trying to get all data from a SQL table. The connection is successful and I can connect to the database, but whenever I run the get request, I end up with an error …
How to find the Group with the Max value
I have a database of students, I have to group them by their class and then find out which class has the most students. I know it’s probably a stupid question but I can’t come to the solution. Sample …
Count number of weeks, days and months from a certain date in PySpark
So, I have a DataFrame of this type: And I want to create multiple columns containing, for each line, the current day, week, month and year from a certain date(simply a year, like 2020 for 2020-01-01). At first I thought of using something like this line of code unfortunately this wouldn’t work (except …
how to rollback tran when error occur in oracle
i try to solve 2 requests below but i only code for the first one,, can any one help to solve the second one Write SQL statements using cursor to update salary of all employees base on update conditionals Make sure all update records have been updated completely. The database transaction will be rolled back i…
Find students who take most courses SQL
Assume there’s a table students containing student id, semester id and number of courses taken in each semester: How can I find students in each semester who took the largest number of courses? Expected output would be: I thought of using OVER PARTITION BY, but I’m not sure how to use it correctly…
Postgres trigger to update counter in another table not working
There is users table and places table. The users table has column id(primary key), username, place_count. The places table has column id(primary key), name, user_id (user_id foreign key) Each user can post multiple photos and so I want the column”place_count” to keep the count of user-specific pla…
How to check collection for null in spring data jpa @Query with in predicate
I have this query in my spring data jpa repository: @Query(“SELECT table1 FROM Table1 table1 ” + “INNER JOIN FETCH table1.error error” + “WHERE table1.date = ?1 ” …
(SQL) Create Table with Distances from Separate Table with XY Coordinates
I am trying to create a table that will have unique distances between slot machines based on the following dataset. I know I first need to calculate my distances and the only way I currently know how would be to use the following code: But this obviously only returns the distance between the first two machine…
Update column using duplicate value counter
I want to calculate the duplicate value counter first, and then use it for another column to be updated. How can I achieve that? first, I have a table below: id another_id 1 null 1 null 1 null 2 …
How to delete part of a string after a specific character, on mutiple rows
I have a table with the batting stats of all National League players from the 2020 season. When I imported the .csv file there was a bit of a formatting issue specifically with the player names Ronald …