Skip to content
Advertisement

Tag: range

Select max entries in a range in SQL server

I have a salary column where I have to select between range of 10000 and 20000 and also the top rows of max salary. Column I have: Rows I want to select I can use top n rows but that will apply on to this column. What I want to do is, say if this column has 2 rows that

How to calculate sum of a value with only “day of week” using a date-range?

I have 2 tables namely Item table with details of item_id, store_id, offer_start_Date and offer_end_date Store table has store_id, day_of_week, store_hours The structure of both tables are follows – 1) Item_Table : Store ID Item ID offer_start_Date offer_end_date NY0001 FMC0001 2021-10-30 2021-11-04 NY0001 FMC0002 2021-11-08 Null NY0002 FMC0003 2021-11-02 2021-11-02 NY0002 FMC0004 2021-09-01 2021-10-10 2) Store Table : Store ID

How can I partition by group that falls within a time range?

I have the following table showing when customers bought a certain product. The data I have is CustomerID, Amount, Dat. I am trying to create the column ProductsIn30Days, which represents how many products a customer bought in the range Dat-30 days inclusive the current day. For example, ProductsIn30Days for CustomerID 1 on Dat 25.3.2020 is 7, since the customer bought

setting time range in SQL Developer

I am working on a dataset that contains car accidents and their time of occurrence. (the data set exists in SQL Server under the name accident). I have a column that is in date format. I would like to extract the time from the column. Then add a new column called lightining_period label the time as daytime or nighttime. My

How to calculate the average value of following n rows based on another column – SQL (Oracle) – updated version of previously answered question

I am trying to calculate average monthly value of PREMIUM for each POLICY_ID in monthly basis as shown below screenshot. When a customer updates his/her yearly PAYMENT_FREQUENCY to a value different than 12, I need to manually calculate the average monthly value for the PREMIUM. In addition, average monthly PREMIUM amount can be changed in time. For instance, for the

Advertisement