Create table for store raw data: Create table for processed data: Now store raw data: I am turning a comma separated string into individual rows: Like this: value 10 2 0 95 15 I want to insert into SplittedAndProcessedData table using a loop, like this: ID count 1 8500 2 8510 3 8512 4 8512 5 8607 6 8622 Which
Tag: sql-server
Pass Minus Values for a SP
I need to pass a value for a SP by multiply it by -1. This is my query and I want pass the quantity by multiply it by -1. Is there any way to do this? Answer change your fist query to negate the sign @Quantity = -qty OR multiply it by -1
Case statement help for replacing null from multiple joins
so i have the following case below where if jl name does not have n/a i want it to come from the same column. if there is n/a i want to look into this subquery and find the recent jl name. but if the …
Is it possible to sum up time field in SQL Server?
I have 3 time(0) column in 1 row. I want to calculate arrival-Time column automatically and this is result of the sum of Departure-Time + Duration is it possible with trigger or computed area method? thanks in advance Answer SQL Server does not support direct addition on time values; however, you can use date…
How to select an element just once in plain SQL
I’ve seen other similar questions to mine, but I haven’t found one that could actually help me. I have a table, defined like so: CREATE TABLE “DOWNLOAD_HISTORY” ( “ID” …
How to use the results of one query in the next query?
I have read answers here but I am still not quite sure how I would do this regarding two columns of a table and more than one result per query. So, the first query would look like this in my Node app: …
If today is friday then extract data 7 to 9 days from today, if not 7 days
If today is Friday, I would like to get data 7 to 9 days from now, if not 7 days. I am using SQL Server. Before: id class startdate 1 English 2020-12-21 00:00:00.000 2 English 2020-12-22 00:00:00.000 3 Math 2020-12-21 00:00:00.000 4 English 2020-12-27 00:00:00.000 5 Math 2020-12-27 00:00:00.000 If today is 14…
Using Over() with aggregate functions while calculating percentage
I am writing a query to print Total Students in each department in a college, I also want to print the percentage of those students in each department out of Total students in the college. Having issues with calculating percentage, the above query throwing an error dbo.Student.Id is invalid in the select list…
Date Format Convert
I am dealing with sql DB where the date is recorded in this format ‘2020-348T08:55’. I need to convert this to datetime. Please guide if there is possible way to do that? Answer With string and date/time functions extract the year and days to create a DATETIME without the time and finally add the …
When inserting multiple record into a SQL table it does not follow the order
When using a single insert statement to add multiple records into a table as shown below, it does not follow the same order when selecting. I understand that it does not affect anything but may I know …