Here is my dataset, where order is the fix sequence of each product. What I want is another column in here, lets say TagID. TagID is an int value that will based on the aggregate Count column, group it by product if it is greater or equal to 5. So the dataset would look like this: How can I accomplish
Tag: tsql
Get Current date, current month, current year depending on user selection – SQL stored procedure
I have a stored procedure that gives results depending on multiple values from the User(filtering), in my query I have 2 date columns date_start and date_end, I want to allow the user to return data depending on his selection from 2dropdownmenu one for start date and the other for end date as this: (this day …
Build a report with SQL with combining columns and rows?
Here is my table: Table Purchase Report PURC_ID CUS_ID Product QTY Date 1 John Leg_01 2 2021-04-09 2 John Head_01 1 2021-04-09 3 Dawn Head_01 1 2021-04-09 4 Dawn Shoulder_01 2 2021-04-09 5 Dawn Leg_01 1 2021-04-09 6 Keith Leg_01 2 2021-04-09 I would like to build the report as follow: Table 4: (PURC table wil…
How to select Maximum and minimum date values and pass those as a query
I have a table with the following entries CustomeID TransDate WorkID 1 2012-12-01 12 1 2012-12-03 45 1 2013-01-21 3 2 2012-12-23 11 3 2013-01-04 13 3 2013-12-24 16 4 2014-01-02 2 I am trying get the data between two dates and the required date values are minimum and maximum values of the column. I am able to …
How to replace identical values with incremental integers?
I have this SQL select: The output will look something like this: How can I replace the identical values of UserId with incremental integers, so that the output will look something like this: I have tried grouping the identical UserId rows first then joining it with the same table while having an incremental …
Query which outputs the number of athletes that voted for someone in the same athletePosition? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question Like the title says, SQL query which outputs the number of athletes that voted for someone in …
Display duplicate row indicator and get only one row when duplicate
I built the schema at http://sqlfiddle.com/#!18/7e9e3 I would like to write a query that would produce the following result characteristics : Returns only one owner per boat When multiple owners on a single boat, return the youngest owner. Display a column to indicate if a boat has multiple owners. So the fol…
Create Continuous Enrollment islands for a certain sub-population
My end goal is to create islands of continuous enrollment days for each CLIENTID for a single sub-population: ‘Adult Expansion’ for calendar years 2019 and 2020. A CLIENTID can be associated with …
Trigger Not Running Check Whether it is correct or not? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question This is my trigger and its running perfectly with the help of stackoverflow.com I edit my ques…
Divide by zero error encountered error. Null value is eliminated by an aggregate or other SET operation
In this specific part of a SP I’m trying to create, I’m getting an error: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Divide by zero error encountered. Additional error <2>: ErrorMsg: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Warning: Null value is eliminated by an aggr…