Skip to content

Tag: sql

how Inner join work on two foreign key from single table

I am working on Bus route management system , I made two table first one is Cities and second one is route have following queries i am joining the table through inner join but it show single column as but i want result as what is possible way to do this using inner join Answer I suspect you need something

Invalid object name ‘sys.dm_exec_input_buffer’

I’m trying to start a script in SQL Server 2014, but it can’t find the object in question. This is the query I am trying to initiate: Error message: Msg 208, Level 16, State 1, Line 1 Invalid object name ‘sys.dm_exec_input_buffer’. Answer You need to be on at least Service Pack 2. If y…

Slow SQL Query / Displaying (PHP / jQuery)

I have a request to get data in my mySQL database (36,848 entries). Then I format and append them with jQuery on my web page. These two operations take 2 minutes and 30 seconds. During this time, no other operation is possible on the page. Is there a way to optimize this to speed up the process? Like this, it…

WITH queries with INSERT in MySQL

I’m trying to do something that I’m almost positive works in Postgresql: In other words, I want to grab the “something” row to be used for a bunch of new rows in “somwhere”. Each new entry should have a reference (like foreign key value) back to the same “something&#8…

Mongodb for projects with many to many relationships

I’m at the beginning of starting a project for learning backend development with a bit of frontend development. For that, I wanted to create a project around cooking recipes. The plan was to create an admin REST API that would be later used by a custom CMS to create, edit, delete,… recipes and a p…

grouping equal values – aggregate function problem

I’ve created a table that lists venues in which several events take place. The same event in the same venue can have a different price. The last column calculates the total revenue for one venue. venue event totalprice sum Venue A Event A 5 30 Venue A Event A 10 30 Venue A Event B 5 30 Venue A Event

Postgres duplicate column based on value in column

I’ve the following table in postgresql id product customer price amount 1 Television Alfred 12.00 1 2 Radio Richard 20.00 3 3 Mobile Richard 40.00 5 Is there some way via SQL to duplicate the line n-times in case the amount is greater than one? This is how the table should look like after running the qu…

Microsoft SQL Server Streak Counter

I have data in the following format: ID Period Date 1 1 2020-09-05 1 2 2020-10-01 1 3 2020-10-30 2 2 2020-10-01 2 4 2020-12-05 2 6 2021-02-05 3 1 2020-09-05 I want to calculate a streak grouping by both ID and period. The first date instance for each group should start at one, and if the date in the