Skip to content

Tag: sql

Reset ROW_NUMBER() when previous partition ID changes

I am trying to reset the ROW_NUMBER() value when there is a change in one of the IDs when sequenced in datetime order. For example in the table below, when Location_ID changes, I want to reset the RowNum to 1. Here’s the statement I am using. I get RowNumX, but want RowNumY. EventDate Scan_Timestamp Ass…

Combine cells in access separated by comma

I am new to access and coding. I have a sheet comprising of huge data. I want some specified data in Access by running a query or VBA. What I want is to combine the data based on a column and each data separated by a comma. I am pasting the example of the sheet below: Input sheet Output data

ASP classic select date BETWEEN dates on SQL Server

I run the next query in my classic asp code and it run perfect. it returns results between the days “from” and “to” However,I cannot find out what is wrong with the next query: I want it to return the results of the last week that are recorded in the database. Any Ideas? The query is o…

SQL – How to print calculated datetime result

If a.modified_datetime is ‘2021/10/01 13:00:00’ and b.modified_datetime is ‘2021/10/01 12:30:00’, the result of this query would be: However, I run this query via sqlplus, it returns What’s wrong with this query, or need to set some options to sqlplus? Answer it is stored in a da…

C# select SQL query with parameter

I would like to migrate database from MS Access to SQL Server and I’m trying to modify my SQL queries. In MS Access they worked. I have this C# code: Connection method : SQL query is working but not returning rows. I guess that problem is a syntax of parameter in query. Can someone direct me? Answer You…

Get percentage of total using sub selection

I have a query that sums sold units and groups them by store. See code and/or SQL-fiddle below: http://www.sqlfiddle.com/#!5/95f29/6 However, I also want the percentage sold by each unit to the total and have therefore created a column named “sold_total”. After the output of this query is generate…