I want to find the max value in a column Above is my table structure. I just want to find the max total value only from the table. In that four row ID 1 and 2 have same value in CName but total val and PName has different values. What I am expecting is have to find the max value
Tag: sql-server
How to auto generate data types for a SQL table
I have many denormalize tables with 200+ columns. These tables are in SQL Server and they often, if not always, have varchar(100) or nvarchar(100) (string) data types. However, most columns are either ints, floats or other data types. It is not possible for me to go through every table & col and pick and …
merge tow querys in sql
I have a issuse in sql query. I have 2 select: The first one showing: columnA|columnB A |2 B |3 D |5 The other one showing: columnA|columnC A |1 B |5 C |7 I’m …
SQL – get summary of differences vs previous month
I have a table similar to this one: It contains the stores that are active at BOM (beginning of month). How do I query it to get the amount of stores that are new that month – those that where not active the previous month? The output should be this: I now how to count the first time that each
Using WITH and subset in CASE construction
Greetings to senior colleagues. I got caught up in this thing. It is necessary to substitute the corresponding values in the CASE when the construction depending on the state of the load_date field. The problem is that the second was assigned a value to the mean_v field based on the calculation of the average…
How to structure limited voting system design
I have 3 types of tables. Categories, Candidates, Voters. To be describing the problem as short as possible, Candidates can belong to only 1 category. Voters can vote for each category and only one …
Assign Unique Group Id To Sets of Rows with Same Column Value Separated by Other value
I have some data that looks like this: What I want is for each group which has the same radius value to have its own unique id, for example: What I don’t want is the second group with radius 10 to have the same groupid as the first group (not 1). I’m working on SQL Server but the solution should
Is it Possible to Merge Rows in SQL from Just One Column?
I wonder if it is possible to merge multiple rows from just one column in SQL. Here’s an example of my initial table: Here’s my expected output: I do not know if it’s possible to have a table like the later one. So, any advice would be much appreciated. Answer This type of task is usually do…
Query to select records belonging only to ID and SUB-ID
I’m trying to construct a query to return only the records related to a given ID and SUB-ID. In case the condition is not met I would like to return the second possibility, i.e, the second combination ID, Sub-ID. Note: The data has thousands of IDs, but only 2 Sub-Ids per ID. This is an example of input…
SQL Combining MAX and SUM
So I have one SQL table that contains the below columns: There are ~2800 unique License numbers and will have numerous FundsIn each day. I am trying to find the last date there was activity (ActivityDate) and the sum of all of the FundsIn on that MAX ActivityDate. Below is a query I’ve been trying to mo…