Skip to content

Store hourly data efficient way

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…

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 …

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)

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

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…