There is a requirement to store hourly data in SQL Server 2016 and retrieve. It’s an OLTP database. I will explain with an example: we need to capture temperature of each city of a country and store on hourly basis. What would be the best and efficient design to do this. The data would be stored for a y…
SQL: How to partition data by the key and transpose the triples in the defined order? (The tool for a human-language translator.)
I do have the table with translated texts to (possibly) many languages. When new text is entered in the chosen language, the lang_hash is calculated. If the text is not bound to any existing text in other languages, the lang_hash is repeated in the key_hash, and–together with the lang code–the new…
How can I use Except all in SQL Server?
I’m trying to use this query statement in order to except daysoff and a duration, let’s called holiday from a calendar of a specific month . This what I have tried : and this is the function of Get_Calendar_Date To except the daysoff ( weekends ) , I have used except , but what I got is something …
GET last element of array in json column of my Transact SQL table
Thanks for helping. I have my table CONVERSATIONS structured in columns like this : [ ID , JSON_CONTENT ] In the column ID i have a simple id in Varchar In the column JSON_CONTENT i something like this : I would like to query and get the id and the last element of exchanges : [ ID , LAST_ELT_IN_EXCHANGE_IN_JS…
How to create teble 3 from data of table 1 and table 2
t1 (ordered descending): a comment 512 (ordered desc) 415 310 205 195 150 132 90 74 20 1 t2 (ordered ascending): b comment 10 (ordered asc) 11 12 13 I would like to create t3: a (desc) b comment 512 10 (b=asc) 415 11 310 12 205 13 195 13 (b=desc) 150 12 132 11 90 10 74 10 (b=asc)
Order By case when then with multiple ASC/DESC [closed]
Hope this question has not been ask already. My problem is : Do you know how to do something like that ORDER BY CASE WHEN job = “jounalist” then 1, date desc WHEN job = “…
How can I select data from last 13 months?
I have two tables with exactly same structure Now I need to ‘union all’ these two tables and I want only last 13 month data every time I run below query I have to run this every month and need only last 13 month data. How can I apply the filter? I have a date column ‘date’ in both the
Extract comma separated values from comma separated GUIDs
I have a column in table T1 named Categories, which contains GUIDs in XML. I am able to extract the GUIDs in a comma-separated form using the below query. SELECT Row, ID, Name, City, Category = …
SQL query filter NULL and current month
I have a SQL query and I would like it to list records that: Are in one of these IDProcessState(s): 5, 6 or 7 If IDProcessState is 7, it should only show the ones that were submitted (DtSubmission) this month If IDProcessState is 5 or 6 it should still show the records (they have null DtSubmission column) The…
Invalid Datatype for user defined table type
I have declared the following user defined table type Now when i pass it as parameter to an SP I keep getting the following error Parameter or variable has invalid datatype Answer You must pass this argument as :