I have a text that contains polygon information Example data: it there any way that could swap “lat” and “lng” in this string in SQL Server? Expect outcome: Any help appreciate! Answer What you have here is JSON. You can break out the info using OPENJSON, swap it round, and rebuild it …
How to delete only Top 100 rows which are older than 30 days from current date in C#? [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 6 months ago. Improve this question When I execute following query , it is executed properly in SSMS but same query in code…
How to count rows by date for each of two values?
I have a large dataset in SQL Server that contains two date fields and a foreign key field (among others): I need a query that can count the number of rows for each day, but to count them for each distinct value in the type_id column. The closest I can wrap my brain around right now is returning the total
sql: Calculate the correlations and convert rows into columns
So my current table has more than 100 fields and I am trying to calculate the correlations between the input variables and output variable, and then convert all those columns into rows. For example, my current table looks like this: input_1 input_2 output 3 6 5 4 7 5 6 4 4 6 9 3 7 10 5 9 9
T-SQL stored procedure: update local variable inside IF/ELSE statement
I have an item table that has a foreign key constraint customer_id that references a customer table. The customer_id column is of type uniqueidentifier which needs to be generated on insert (there is no value we could use for this provided by the client). I am created a T-SQL (using SQL Server Express) stored…
Presto – Convert Table into Map
I would like to convert the below table into a map with multiple key/value pairs label_a label_b 1 2 3 4 5 6 into {‘label_a’ -> 1, ‘label_b’ -> 2} {‘label_a’ -> 3, ‘label_b’ -> 4} {‘label_a’ -> 5, ‘label_b’ -> 6} What wo…
SQL, casting a string to date so I can use GETDATE()
I am using SQL Server Management Studio 18 against SQL Server 2016. I have some material that are in batches and those batches have expiration dates that are held as strings, but are basically in the format of ‘yearmonthday’, e.g. ‘20210312’ for March 3rd, 2021. My goal is to only see …
How to create partitioned table from other tables in Amazon Athena?
I am looking to create a table from an existing table in Amazon Athena. The existing table is partitioned on partition_0, partition_1, and partition_2 (all strings) and I would like this partition to carry over. Here is my code: Trying to run this gives me an error at the FROM line, saying “mismatched i…
find the consecutive values in impala
I have a data set below with ID, Date and Value. I want to flag the ID where three consecutive days has value 0. id date value 1 8/10/2021 1 1 8/11/2021 0 1 8/12/2021 0 1 8/13/2021 0 1 8/14/2021 5 2 8/10/2021 2 2 8/11/2021 3 2 8/12/2021 0 2 8/13/2021 0 2 8/14/2021 6 3 8/10/2021 3
query to get data between date ranges and the padded data around
suppose this is my data in a table in the database and this is my query to fetch data I would also like the query to return one date before and after this range. so like the dates padded. Now how can i do this efficiently. One way could be to get the dates in the ranges and then get