I have a Table with SalesPerson and Sales for different dates. I have another table where I have SalesPerson and multiple date ranges where different Adjustment factor needs to be applied. I can do …
Tag: sql-server
My query works but I need to make is scalable. I need to remove unions but not sure how to proceed
I need a list of the number of times a file has processed through our system. For example in week 1, for a given warehouseID, x number of files have processed 1 time, x number have processed 2 times, …
syntax error in a nested “sum(case when” statement
I have a database with information from several companies that record their data differently. To mark what is a credit memo/finance charge/invoice/etc- 3 companies use a certain field, while 3 of the …
Is the ‘WITH’ clause only syntactic sugar?
I’m trying to find the best way to iterate over the same set of data multiple times in a single query, and in the way I started wondering wether ‘with’ would save some execution time (by reducing the …
years between two dates in sql server with starting and end date of each of them in sql server
i want to get years between two dates with their starting and end dates.Suppose if i enter startdate as “07/06/2017” and enddate as “18/09/2019”, i want list the years in between with their starting …
SQL | Display all rows where date is not current month
I have two tables In one table there are my employees and when they changed the Department In the second table there is my current date Employee Table +——————+——–+————-+-…
SQL – Variable formule to calculate prices
I’m in need of the correct code syntax that calculates the price after discount for the following 4 scenarios. Please note that I’m looking for a variable solution as the amount of commas in the …
How to manipulate the output after selecting and ordering TOP RESULT
ERROR: Msg 156, Level 15, State 1, Server NS544979, Procedure , Line 0 Incorrect syntax near the keyword ‘TOP’. [42000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near the keyword ‘TOP’. (156) I have successfully selected and ordered the PvPExp in the query.…
Rounding of hours in sql queries
The values you see below are loaded with a query and they are related to a time stamp. What they ask me to insert is a rounded value; up and down. Rounding must be done at minutes of 15 and 30. If …
Query for two tables with similar information
I am working on some baseball stats to improve my database abilities I have data for hitters from 2017 and 2018 MLB seasons. what I hope to accomplish is to average the number of games played, at bats …