I’ve stored procedure like this: We can execute the above stored procedure by: The written sp provides data based on pagination and we can retrieve 100 or any number of records by passing a number in @int_grid_size . The table output looks like following: The last column gives the total records count of…
Tag: sql-server
Windowing functions cumulative aggregation
I am calculating cumulative by summing some columns. The code is working. But I want to include an extra variable for the first line only. Then it miscalculates. What I want to do in line 1: What I want to do except line 1: When I do this with case, the wrong result is obtained. SQL code: So for example
How can I get a query displayed monthly with a subquery
I have a query here with a subquery. This shows me the complete result for the year. How do I get it to be displayed to me on a monthly basis. I’ve tried a few things but always get an error message Here my query The result should look like this: Thank you Answer You can probably simplify this by
Write a SQL query with a subquery in .NET Core using Entity Framework that returns a list of items with varying number of returned child rows
I have this test SqlFiddle: http://sqlfiddle.com/#!18/05fce/1 The idea is that for each product (table webspiderproduct) it will return the lowest price from each shopId from the table webspiderproductprice. So the returned data should look like this: I am using SQL Server. In pseudocode should I write a and …
SQL for Calclate sum of Sales At particular time every day
Order Table.Reprpesents Order Date and Created is time at which record was inserted The laltest record in this table is at(Created value) – 05:17:38.710 Output – 2021-12-26 05:17:38.710 At this time on 26th i.e. today’s date the sales was At the same time I want to know the sales on 25th I w…
Finding who called who
I have these two tables. Subscriber table contains SubscriberID and his Phone number. NetworkP2P contents SubscriberID, to who he has called AddresseeNumber and when the call started, ended. Example data: Subscriber NetworkP2P Not all Phone numbers match the ones that Subscribers have. How would I approach th…
Migrating from sql to mysql
I want to transfer a database that I created with sql server with the information in mysqle. An example sql file is as follows No connection to the database should be interrupted during this migration. SQL File Answer Given the length of the script, it would be best to you use an online converter. A good choi…
Need to update column from derived column of select statement
I’ve this below select statement. Over there I’ve 2 derived columns EmpContbtnWithoutTax and EmpContbtnWithTax I wanted to have that data permanently in that same table EmpPFContributionTest Need help to have that update query for EmpPFContributionTest table which update the respective rows of Emp…
SQL Server query to filter the financial year when month and year are in different columns
I’ve attached the sample data. Here actually I wanted to calculate the running total of emp_contribution and vpf column together. however that should be bounded within a financial year. suppose for 2015 it will start from April, 2015 to March, 2016. This is where I’m facing the challenges. Below I…
Case statements with Join on lookup
I have a big table with some columns having lookup values. I want to create a description column for each lookup column and populate them with description from lookup table. Here is one example main table id1 id2 id3 1 2 3 1 3 4 look up table code id desc id1 1 id1-desc1 id2 2 id2-desc2 id2 3 id2-desc3