I have about 70 million rows of data with a column that contains numbers, but it’s in a float format. I need to get rid of the last 4 digits of that column i.e. I need to turn this 60871003002001 …
Tag: sql-server
SQL – Convert ROW_NUMBER function with multiple order by
I am trying to convert this query to a subquery without the ROW_NUMBER function: SELECT InvestorFundId, AsOfDate, AddedOn FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY InvestorFundId ORDER BY …
SQL SUM on multiple INNER JOIN
I am trying to get the sum of particular fields through multiple table using joins. I am getting the SUM wrong when I I try to get the values together. I have table State as I have another table Balance as I have one more table Loan as What I want as a result from my query is, When I
Get list of SQL server databases which files have been deleted
My goal is getting list of SQL server databases which files have been deleted. In other words. I attach a db from mount, then close the mount so actually I have the attached db without files. At …
Return first order by each month
I am trying to modify my current query to return the first order for each month in each year. Here is my full table and my current query. select orderdate, sum(UnitPrice*Qty) AS …
How to in insert new rows from one table to another based on date?
I am having two tables (table1 and table2). I have columns Date, A, B, C in table1 and columns Date, D, E in table2. I need to transfer column D and E from table2 to table1 based on Date in both the tables. I tried below code but getting ‘multi-part identifier “table1.Date” could not be boun…
SQL Server: Update table based on JSON
I am trying to update rows in table based on JSON I have. JSON has the following structure: Table dbo.sensors has same structure + few more columns. To insert such JSON object, not array, into table, I would do it this way: So I have 2 questions: how to iterate over each element in JSON array and update each …
Extract string between double quotes in SQL
I have a string and I need to return the characters between the double quotes ‘((“Name 1” and “Name 2”) or “Name 3”) I need to return I have used the function below to split the string but I am getting the (( and the Or and AND etc .. which I don’t want and unfo…
Issue converting JSON string into decimal
This question may answer on many threads but I am unable to find answer specific to my problem. Q: I am getting data from API (in json format) where all columns are coming as string and inserting …
Filter out certain rows based on condition
I have this Input Table: I want to check each project separately then exclude If the project owner has his name inside col2 and other people with him, then remove the row which is repetitive Jack Jack, a. For example, In Project B Jack has his name inside Col2 and he is working with Maria , so remove Jack Jac…