Categories
Database Development

How to calculate end_date from start_date and duration in SQL Server Query

I have a table with 4 fields .Start-date, Duration, End_date, Actual_date. I am providing the start_date and duration as the input to calculate end-date. While calculating the end_date the Saturday and Sundays are not considered.Also if the actual_date is having value that value is saved as end_date. Example : Start_date = 18/05/2020 , Duration : […]

Categories
Mastering Development

Data not being shown on MySql Workbench

I am doing a simple program that maps data from an excel file into a mysql DB, using Java and JDBC for that purpose, as well as MySQL Workbench. I noticed in one of the tables, that even tough the code itself gave no error, when I checked the table via MySQL Workbench nothing appeared […]

Categories
Mastering Development

how can I set the reducer’s return value to state object in component in react js

I have one component as below. I am calling on api on its componentDidMount() event. I am not getting why am I not getting its prop value first time when component renders. Also I am not sure why component is rendering 2 times. I have below code. import React, { Component } from “react”; import […]

Categories
Mastering Development

subquery returned more than 1 value table join

I am writing a course project (something like a program for the hotel manager) and I need a little help. I have tables Reservations and Rooms and I need to calculate the amount of payment after the client leaves the room ((End_date – Start_date) * price_per_day), but I’m having trouble getting the price_per_day from the […]

Categories
Database Development

How could you improve the performance of this query from a database that gets the same results?

SELECT `tab2`.`nome_escola`, `tab2`.`tipo`, `tab2`.`pro`, `tab2`.`school_id`, `tab2`.`fase1`, `tab2`.`fase2`, `tab2`.`fase3`, `tab2`.`fase4`, `tab2`.`olympic_title`, `tab2`.`user_id_int` AS `user_id`, `tab2`.`total_points`, `tab2`.`class_name`, IFNULL(SUM(pontos_obtidos_period), 0) AS total_points_period, `tab2`.`ano` AS `id_year`, `u`.`first_name` AS `name` FROM ( SELECT user_id_int, total_points, ub.action_id, ub.question_id, start_date, end_date, ano, opi_created, school_id, nome_escola, tipo, pro, olympic_title, class_name, MAX(CAST(ub.value AS UNSIGNED)) AS pontos_obtidos_period, IFNULL((select opn2.points from olympic_players_niveis opn2 where opn2.user_id = […]

Categories
Database Development

Calculate the duration in an interval and outside of events that can last over several days

I need to calculate the total duration of events in a given time interval and on a given day of the week with PostgreSQL 11 For an event on the same day no problem. But over several days I manage to approximate the result with “generate_series”.u Is there another way faster and more precise? Interval […]

Categories
Database Development

PostgreSQL 11 Calculates the duration in an interval and outside of events that can last over several days

Good morning, everybody. I need to calculate the total duration of events in a given time interval and on a given day of the week with PostgreSQL 11 For an event on the same day no problem. But over several days I manage to approximate the result with “generate_series”.u Is there another way faster and […]

Categories
Database Development

Checking an overlapping date

I have a column start_date and end_date on my DB. My input is a date range and I need to check if my input dates overlap with my DB start_date – end_date. May I have your inputs on how I can start on this, please. Or is there a way where I can do something […]

Categories
Mastering Development

How can i handle django nested models?

I have a User, Post and Tag model in Django. Tag model is not relevant for this topic. I am trying to get all the data in the front end with nested objects. I can succesfully did that.When i want to create a new post i send the post data to django and in django […]

Categories
Mastering Development

I’m trying to send data to a parent table and also one of its three child tables. Only one of the child tables work and i cant figure out why

I’m using MySQL and PHP with XAMPP. I can not figure out if this is a problem with my database or with my PHP. In lines 28-96 (i made a comment in the code so you can see which ones I’m referring to) The capstone child table works. If I select capstone as the project […]