I want to get the records from Dec-1-2019 to Dec-31-2019 but I am not getting any records from the database while checking with out date filter the records are coming. There are records in the database table between these days but not coming. Query Sample data C# Code Answer Consider specifying an ISO 8601 da…
Tag: sql-server
Group rows by dense_rank() and loop through each sub-group and compare another column in next row of that sub group?
I have tried the following in LINQPad: I want to write a query which will return only the IDs 1 and 2 (not 3 and 4) because: ID 1 – has more than 1 rows and startdate of its rownum 2 is 1 day ahead of enddate of its rownum 1 ID 2 – has more than 1 rows and
Recursive CTE have performace issue, need suggestion to optimize query
I wanted to get TOP 5 records from log table where “Approve date” is changed like NULL to value and vice versa. Date value is doesn’t matter, but order matters. In this case I want first record and 5th record (Someone approved the data that’s why a value),then 7th record value is null someon…
How to merge many rows with the same ID with SQL Server
I need the help from the community to solve the following problem that I found (I’m using SQL Server): I have two tables, USER and INFO. USER: ID NAME ———- AAA John BBB Mike INFO: ID …
SQL Join on table with revision dates
I am about to begin working on a solution for my company in SQL that requires me to link product category mappings based on a SKU number. The problem is that the category mappings can change, and they will have a date associated with the change. For example: Product 1 is currently mapped to category A. User r…
Number based on condition
I’m trying to generate a number based on a condition. When there is yes in column ‘Stop’ in the partition of a Client ordered by Start_Date, the Dense Rank has to start over. So I tried several things but it’s stil not what I want. My table with current number and expected number The q…
Trying to Update Case When Then, based on matching IDs in two tables
I am trying to updated IDs in a table named Price, based on matches of IDs in a table named CW. Here is the SQL that I’m testing. UPDATE Price SET ISN = (case when CW.id_cd = ‘ISN’ THEN CW….
NZ function in T-SQL where ValueIfNull is NOT specified
I am working on an MS Access to SQL Server Migration project and am currently in the process of converting a complex query into T-SQL from MS Access. Now I’m quite familiar with how Nz works in Access …
How can I convert an EAV schema to a normal schema using PIVOT?
I have a table called SourceTable, in that I have 4 fields. Properties_title field it has got 3 values (AAA,BBB,CCC) but can also have more. Depending on each of them, NumericValue field and Property_item_title field has a value.According to the table in the below, if Properties_title be AAA or CCC so Propert…
Select values from table having a field value same as another field value
I have the following columns in a table : FDA_ID and FDA_ID_PARENT and the following set of data: FDA_ID | FDA_ID_PARENT 771 | NULL 772 | 771 773 | 771 774 | 0 775 | …