Transact SQL :: How To Make A Report On Difference Between Rows
Nov 16, 2015
Given a table that has three columns that together create a key and two columns that together define NameValue pairs, how can the difference between instances of values be calculated and displayed?One table is used to contain periodic dumps of data from various sources. Because this is an early stage of development for the software project instead of having explicit columns that contain specific data the table contains name/value pairs. This allows the software to export anything to the database table. When this data is imported, earch row shares the same key (three columns containing a machine type, serial number and a timestamp), a name that identifies the data and a string that contains the actual data. While this arrangement makes it trivial to support the addition of any data that the software developers want to export, it makes it less obvious as to how to generate reports.Let's make an example. Lets assume that there are two vending machines, each of which has just 3 snacks and each of which generates two separate reports.
Type Sn Timestamp Name Value
A 1 2015-08-15 12:34 Snick 5
A 1 2015-08-15 12:34 Mars 10
A 1 2015-08-15 12:34 MandM 0B 2 2015-08-15 15:31 Snick 1
B 2 2015-08-15 15:31 Mars 9
B 2 2015-08-15 15:31 MandM 0A 1 2015-08-21 09:12 Snick 11
A 1 2015-08-21 09:12 Mars 18
[code]...
So, the names of the values become the report's columns. The reports are sorted by timestamp, then by type, then by serial number.The value associated with the previous row that shares the same name is subtracted from the value of the next row in which the same name occurs and that becomes the displayed value in the report.
View 8 Replies
ADVERTISEMENT
May 8, 2015
how to measure a change in inventory over various stores. Â My sql2008R2 express db gets a new row of data everyday from each store(about 40 stores) for a single product stock count "OnHand" and if there is any new stock on order. Â When the new stock arrives it is added to the "OnHand" count. Â I want to measure the delta change per day,per store. Â I'm stuck on how to separate the stores and how to query the delta of stock.My data base looks like this
               Â
TimeStamp Store
OnHand OnOrder
2015/04/22 18 Â Â 1 - Concord
12
   0
2015/04/23 11 Â Â 1 - Concord
11
Â
[code]....
View 17 Replies
View Related
Jun 21, 2015
I have a table data like below
id     type    timestamp
1001Â Â Â start1Â Â Â 10:34:23:545
1001Â Â Â start2Â Â Â 10:34:24:545
1001Â Â Â end2Â Â Â 10:34:24:845
1001Â Â Â end1Â Â Â 10:34:25:545
1002Â Â Â start1Â Â Â 10:34:25:645
1002Â Â Â start2Â Â Â 10:34:25:745
1002Â Â Â end2Â Â Â 10:34:25:945
1002Â Â Â end1Â Â Â 10:34:25:965
I need the result as follows
id        millisecond diff start1end1               millisecond diff start2end2
1001   end1 timestamp-start1 timestamp   end2 timestamp-start2 timestamp
1002   end1 timestamp-start1 timestamp  end2 timestamp-start2 timestamp
SQL Server 2008 R2
View 5 Replies
View Related
Sep 22, 2015
Here is the table:
empid lastname firstname title titleofcourtesy ModifiedOROriginal
1 Davis1 Sara CEO Ms. Modified
1 Davis Sara CEO Ms. Original
We need an output like this:
empid
1
1
lastname
Davis1
Davis
firstname
Sara
Sara
title
CEO
CEO
titleofcourtesy
Ms.
Ms.
ModifiedOROriginal
Modified
Original
View 2 Replies
View Related
May 18, 2015
I have persons who speaks multiple languages and they are in one table, each row is added if he/she speaks multiple languages. Instead I want to add additional columns and load the data.(what I have shown in the desired output)
name language
-------------
ron  english
ron  french
ron  spanish
andy  english
andy  hindi
kate  english
Desired output
name language1 language2 language3 language4 language5 language6
-----------------------------------------------------------------
ron  english  french   spanish
andy english  hindi
Kate englishÂ
View 4 Replies
View Related
Aug 5, 2015
equipmentid downtimestartdate downtimeenddate  dowtime
a3er 2015-03-15 02:00 2015-03-17 23:00 Â Â Â Â Â Â 69
b6e4 2015-03-18 13:00 2015-03-20 04:00 Â Â Â Â Â Â 39
i have many rows(in our production table, thousands of rows are there) like above in a table and i want like below output(in output total 6rows only)
equipmentid downtimestartdate downtimeenddate dowtime
a3er      2015-03-15 02:00 2015-03-15 24:00       22Â
a3er      2015-03-16 00:00 2015-03-15 24:00       24
a3er      2015-03-17 00:00 2015-03-15 23:00       23
[code]...
View 2 Replies
View Related
Sep 7, 2007
Imagine the following scenario-
Identity(1,1) column ID is primary key and only clustered index key.
Rows will be inserted regularly into this table, hundreds per day.
Queries will be mostly selecting on the most recent records.
In a year, the row will have half a million records or so and only the most recent records will be used. There will be a forward-rolling hot spot, of most recent records.
Does the direction of the ID column in the clustered index make a difference?
I'm thinking no, because query plan will go to that leaf in an index seek regardless of whether it is old or new, "bottom" or "top" of index, especially if the query is very specific on the ID.
I've read this
http://mattadamson.blogspot.com/2005/05/choosing-between-ascending-or.html
but it didn't address (or perhaps didn't need to) this sort of scenario.
View 3 Replies
View Related
Sep 27, 2007
outside of restore manageability, can multiple filegroups enhance performance when only one disk is attached? I guess I should also ask if it can hurt?
I have two use cases and am a bit unclear after reading lots of material on the subject.
My first use case is an OLTP consisting of a very stable set of "configuration" tables and a volatile transaction intake table with RI on the stable tables. I thought about putting the volatile table in it's own filegroup due to it's behavior but am second guessing myself after seeing that every author on the subject seems to hint that filegroups are only relevant when they map to different disks.
My second use case is an archive (readonly) that I will "range" partition due to volume. My first instinct was to create one filegroup for each partition but again I'm wondering what that will buy me in an environment with only a single disk.
View 3 Replies
View Related
May 21, 2007
My table is something like this
Col1 Balances
1000 1000
900 100
20 80
50 30
I want the balance to be calculated as (PreviousRecord
Balance-CurrentCol1)
Eg:1000-900=100
100-20=80
80-50=30
Please Help
View 3 Replies
View Related
Aug 24, 2015
select count(cars.carid)
from
Cars left
join
RentalOrders
on
cars.CarID=RentalOrders.CarRef
where carid not
in(selectRentalOrders.CarRef
from
RentalOrders)
when I wrote this above-query for sofiacarrental_v2.2 it shows 30 in the result but when I changed it this query to that:
select count(cars.carid)
 from
Cars left
join
RentalOrders
on
cars.CarID=RentalOrders.CarRef
where not exists
(select
RentalOrders.CarRef
from
RentalOrders)
I replaced not in with not exists it showed 0 in the result.there is any point in term of using them or I made a mistake in the second query?Â
View 2 Replies
View Related
Jul 6, 2013
I encountered a tricky problem. The original data, say, table_o, is shown below:
IdsStatusDate
ID1402-May-13
ID1310-May-13
ID1216-May-13
ID1120-May-13
ID2308-May-13
ID2210-May-13
ID2119-May-13
The final resulting table, e.g., table_f, is:
Ids4->3 3->2 2->1
ID18 6 4
ID2NULL 2 9
The values in the final table are the days used by each ID transferring from status i to status i-1. E.g., ID uses 8 days (10-May-13 - 2-May-13) to go to status 3 from status 4.
It is hard for me to come up with a table like the final table, although I know that the difference between two adjacent rows can be computed by using self-join and timediff().
View 3 Replies
View Related
Nov 27, 2007
This is tricky so please read it through
For displaying data on the report I am using the following query
SELECT ReferenceNumber, ActivityID, ActivityTimeStamp, ActivityType, ActivityPerformedBy FROM ActivityDetails
ORDER BY ReferenceNumber, ActivityID
The result set is
Issue Reference #
Activity ID
Activity Date/Time
Activity Type
100819
4521404
11/4/07 2:06 PM
INIT
100819
4521405
11/4/07 2:07 PM
LOG
100819
4521406
11/4/07 2:07 PM
LOG
100819
4521473
11/4/07 2:28 PM
TR
100819
4521501
11/4/07 2:33 PM
WIP
100819
4521839
11/4/07 3:25 PM
RE
100819
4521844
11/4/07 3:27 PM
RE_Method
100819
4522575
11/4/07 8:53 PM
CL
100820
4521412
11/4/07 2:10 PM
INIT
100820
4521419
11/4/07 2:13 PM
ATTACHTDOC
100820
4525856
11/5/07 2:49 PM
ATTACHTDOC
100820
4525859
11/5/07 2:49 PM
LOG
100820
4525869
11/5/07 2:49 PM
CL
100821
4521423
11/4/07 2:14 PM
INIT
100821
4521425
11/4/07 2:14 PM
LOG
100821
4521429
11/4/07 2:14 PM
TR
100821
4521432
11/4/07 2:14 PM
ACK
100821
4522219
11/4/07 4:58 PM
RE
100821
4522221
11/4/07 4:58 PM
RE_Method
100821
4522447
11/4/07 6:51 PM
CL
On the report I have used the grouped by clause on 'Issue Reference #'. I want one more column which would calculate the difference between two consecutive Activity Date/Time of the same reference #.
e.g. Time difference between 4521404 and 4521405, 4521405 and 4521406, 4521406 and 4521473 etc. Please note that the difference between 4521412 and 4522575 will NOT be calculated since they are from different Reference Numbers.
Thanks,
View 2 Replies
View Related
Sep 26, 2006
Hi all,
I have a table named Orders and this table has two relevant fields: CustomerId and OrderDate. I am trying to construct a query that will give me the difference, in days, between each customer's order so that the results would be something like: (using Northwind as the example)
...
ALFKI 25/08/1997 03/10/1997 39
ALFKI 03/10/1997 13/10/1997 10
ALFKI 13/10/1997 15/01/1998 94
ALFKI 15/01/1998 16/03/1998 60
ALFKI 16/03/1998 09/04/1998 24
...
At the moment, I have the following query that I think is on the right track:
€¦
SELECT dbo.Orders.CustomerID, dbo.Orders.OrderDate AS LowDate, Orders_1.OrderDate AS HighDate, DATEDIFF([day], dbo.Orders.OrderDate, Orders_1.OrderDate) AS Difference FROM dbo.Orders INNER JOIN dbo.Orders Orders_1 ON dbo.Orders.CustomerID = Orders_1.CustomerID AND dbo.Orders.OrderDate < Orders_1.OrderDate GROUP BY dbo.Orders.CustomerID, dbo.Orders.OrderDate, Orders_1.OrderDate, DATEDIFF([day], dbo.Orders.OrderDate, Orders_1.OrderDate) ORDER BY dbo.Orders.CustomerID, dbo.Orders.OrderDate, Orders_1.OrderDate
€¦
However, this gives me too much data:
€¦
ALFKI 25/08/1997 03/10/1997 39
ALFKI 25/08/1997 13/10/1997 49
ALFKI 25/08/1997 15/01/1998 143
ALFKI 25/08/1997 16/03/1998 203
ALFKI 25/08/1997 09/04/1998 227
ALFKI 03/10/1997 13/10/1997 10
ALFKI 03/10/1997 15/01/1998 104
ALFKI 03/10/1997 16/03/1998 164
ALFKI 03/10/1997 09/04/1998 188
ALFKI 13/10/1997 15/01/1998 94
ALFKI 13/10/1997 16/03/1998 154
ALFKI 13/10/1997 09/04/1998 178
ALFKI 15/01/1998 16/03/1998 60
ALFKI 15/01/1998 09/04/1998 84
€¦
So, do any of you have any ideas how I might achieve this? I know how to do it using a stored procedure, but I am trying to avoid that; I€™d like to do this in a single query.
Thanks for any help you have to offer,
Regards,
Stephen.
View 4 Replies
View Related
May 15, 2006
Hi,
i have a matrix, and in that matrix i need to have one column which calculates the percentage change between a value on the current row and the same value on the previous row.
Is this possible? The RunningValue() function isn't of help as it can't help me calculate the change between two rows, and Previous() doesn't work in a matrix (why???!!!!!). Also calculating this as part of the query isn't possible as there is a single row group on the matrix, and the query is MDX.*
Thanks,
sluggy
*for those who are curious, the matrix is showing data an a per week basis, the row group is snapshot date, i am trying to measure the change in sales at each snapshot.
View 8 Replies
View Related
Jul 28, 2015
I have a SQL table like this
Events time endTime
Tram 2014-11-28 12:35:50.390 2014-11-28 12:43:19.120
Re-Entry 2014-11-28 12:43:19.120 2014-11-28 12:56:07.040
Tram 2014-11-28 12:56:07.040 2014-11-28 13:15:25.060 // EndDate Before dump
Dump 2014-11-28 13:15:25.060 2014-11-28 13:50:07.233
Tram 2014-11-28 13:50:07.233 2014-11-28 13:55:17.473
Load 2014-11-28 13:55:17.473 2014-11-28 14:06:55.063
Tram 2014-11-28 14:06:55.063 2014-11-28 14:37:12.100
Dump 2014-11-28 14:37:12.100 2014-11-28 14:37:12.100
I want to calculate the Difference between 2 dates like endtime before Dump -time..I am expecting output like this
ROW1 Â ROW2
 1   00:39:34
 2   23:12:55
You can find the details in SQL Fiddle here.
View 4 Replies
View Related
Jun 18, 2015
I have a table that will be loaded over night everyday and I need to write a query on running value difference ?
List of Columns (ID, Branch ,Group, Date, Value)
ID   Branch  Group  Date                 Value
1Â Â Â Â Â Â Â AÂ Â Â Â Â Â Â Â Â Â CÂ Â Â Â 2015-06-01Â Â Â Â Â Â Â Â Â Â Â 10
2Â Â Â Â Â Â Â AÂ Â Â Â Â Â Â Â Â Â CÂ Â Â Â Â Â 2015-06-02Â Â Â Â Â Â Â Â Â Â Â 15
3Â Â Â Â Â Â Â AÂ Â Â Â Â Â Â Â Â Â CÂ Â Â Â Â Â 2015-06-03Â Â Â Â Â Â Â Â Â Â Â 25
4Â Â Â Â Â Â Â Â AÂ Â Â Â Â Â Â Â Â Â CÂ Â Â Â Â Â 2015-06-04Â Â Â Â Â Â Â Â Â Â Â 20
5Â Â Â Â Â Â Â Â BÂ Â Â Â Â Â Â Â Â Â DÂ Â Â Â Â Â Â 2015-06-01Â Â Â Â Â Â Â Â Â Â Â 20
6Â Â Â Â Â Â Â Â BÂ Â Â Â Â Â Â Â Â Â DÂ Â Â Â Â Â Â 2015-06-02Â Â Â Â Â Â Â Â Â Â Â 25
7Â Â Â Â Â Â Â Â BÂ Â Â Â Â Â Â Â Â Â DÂ Â Â Â Â Â Â 2015-06-03Â Â Â Â Â Â Â Â Â Â Â 10
8Â Â Â Â Â Â Â Â BÂ Â Â Â Â Â Â Â Â Â DÂ Â Â Â Â Â Â 2015-06-04Â Â Â Â Â Â Â Â Â Â Â 20
I want the Output like below with a Running value difference in comparison to previous day.
ID   Branch  Group  Date         Value   Running Value
1Â Â Â Â Â Â Â AÂ Â Â Â Â Â Â Â Â Â CÂ Â Â Â 2015-06-01Â Â Â Â Â Â Â Â Â Â Â 10Â Â Â Â Â Â Â Â 10
2Â Â Â Â Â Â Â AÂ Â Â Â Â Â Â Â Â Â CÂ Â Â Â Â Â 2015-06-02Â Â Â Â Â Â Â Â Â Â Â 15Â Â Â Â Â Â Â Â Â 05
3Â Â Â Â Â Â Â AÂ Â Â Â Â Â Â Â Â Â CÂ Â Â Â Â Â 2015-06-03Â Â Â Â Â Â Â Â Â Â Â 25Â Â Â Â Â Â Â Â 10
4Â Â Â Â Â Â Â Â AÂ Â Â Â Â Â Â Â Â Â CÂ Â Â Â Â Â 2015-06-04Â Â Â Â Â Â Â Â Â Â Â 20Â Â Â Â Â Â Â Â -5
5Â Â Â Â Â Â Â Â BÂ Â Â Â Â Â Â Â Â Â DÂ Â Â Â Â Â Â 2015-06-01Â Â Â Â Â Â Â Â Â Â Â 20Â Â Â Â Â Â Â Â 20
6Â Â Â Â Â Â Â Â BÂ Â Â Â Â Â Â Â Â Â DÂ Â Â Â Â Â Â 2015-06-02Â Â Â Â Â Â Â Â Â Â Â 25Â Â Â Â Â Â Â Â 05
7Â Â Â Â Â Â Â Â BÂ Â Â Â Â Â Â Â Â Â DÂ Â Â Â Â Â Â 2015-06-03Â Â Â Â Â Â Â Â Â Â Â 10Â Â Â Â Â Â Â Â -15
8Â Â Â Â Â Â Â Â BÂ Â Â Â Â Â Â Â Â Â DÂ Â Â Â Â Â Â 2015-06-04Â Â Â Â Â Â Â Â Â Â Â 20Â Â Â Â Â Â Â Â 10
Basically I need to compare the previous day and show the difference. How can I do this in SQL 2008 r2?
View 6 Replies
View Related
Aug 10, 2015
What is the difference between the Index and the Primary Key?
View 14 Replies
View Related
Jul 24, 2015
I have a SQL script to insert data into a table as below:
INSERT into [SRV1INS2].BB.dbo.Agents2
select * from [SRV2INS14].DD.dbo.Agents
I just want to set a Trigger on Agents2 Table, which could delete all rows in the table , before carry out any Insert operation using above statement.I had below Table Trigger on [SRV1INS2].BB.dbo.Agents2 Table as below: But it did not perform what I intend to do.
USE [BB]
GO
/****** Object: Trigger   Script Date: 24/07/2015 3:41:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
[code]....
View 3 Replies
View Related
Feb 4, 2015
I have here a query which delivers me the user data from the last month. The problem what I have is, if employee have more then one rows in this month, they will be also deliverd. But exactly this is not needed. I need only the last record from last month.
SELECT a.FIRMA,
a.PSNR,
a.FELDNR,
a.PFLFDNR,
a.INHALT AS FTE,
a.PFGLTAB,
[Code] ....
Result from Query at the moment:
FIRMAPSNRFELDNRPFLFDNRFTEPFGLTABPFGLTBISKSTNRPSPERSNR
1351022112013082820320101000084000895
14702220,912014100120320101000079000057
1166022112011010120320101000077000543
1364022112013100120150114000072000920
136402220,942015011520321231000072000920
As you can see, PSNR=364 has two rows and i need only the row from last month and last date.Maybe we can use Field PFLFDNR as counter. get only one row for every employee?
like this
FIRMAPSNRFELDNRPFLFDNRFTEPFGLTABPFGLTBISKSTNRPSPERSNR
1351022112013082820320101000084000895
14702220,912014100120320101000079000057
1166022112011010120320101000077000543
136402220,942015011520321231000072000920
View 10 Replies
View Related
Oct 23, 2007
Hi,
I am working on a matrix report shown as below: the first one is what i got now, the second one is what I desire to have
Quarter1
January
February
March
Total
CCC
2006
9
9
19
37
2007
2
17
15
34
CHTDS
2006
5
15
10
30
2007
6
8
9
23
FTA
2006
4
9
3
16
2007
4
4
6
14
GDA
2006
9
8
12
29
2007
15
7
16
38
Quarter1
January
February
March
Total
CCC
2006
9
9
19
37
2007
2
17
15
34
Diff
-7
8
-4
-3
CHTDS
2006
5
15
10
30
2007
6
8
9
23
Diff
1
-7
-1
-7
FTA
2006
4
9
3
16
2007
4
4
6
14
Diff
0
-5
3
-2
GDA
2006
9
8
12
29
2007
15
7
16
38
Diff
6
-1
4
9
How can I get the difference between 2006 and 2007 for each category as highlighted in yellow?
Thanks,
xhh
View 3 Replies
View Related
May 28, 2015
What is the difference between Heaps and Balanced Trees? Is it true that if a table has no clustered index it is a heap?
If so , if the table has only Non clustered index, is it still a Heap?
View 4 Replies
View Related
Sep 25, 2015
I want a difference in daysÂ
Select datediff(dd,Target_Date,Achv_Date)Â
Now , checks areÂ
1] when target date greater than achv_Date the difference should be greater than 0Â
means for FileIDÂ 77608Â
Select datediff(dd,'2015-09-24 00:00:00.000','2015-09-24 10:42:32.823')
Â
i am getting -6 it should be 6 cant switch Target_Date and Achv_Date in datediff else i will get opposite result in first four records basically, i want a two column TAT and Status beside  achv_date based on the values of two dates difference see above ..and also want a result of (No. of Yes in status / No. of Files that has achv_date )i.e. result= (7/8) = 87%Â
View 6 Replies
View Related
Jun 19, 2015
What is the difference between Batch and Stored Procedure?
View 5 Replies
View Related
Jul 10, 2015
Currently my script is using the below mentioned query to find the time difference.
DATEDIFF(HH,DATEADD(SS,hcreacion,fcreacion) ,DATEADD(SS,hcerrar,fcreacion))
If there is 1 hr 30 minutes time difference, I am getting 2 hours as output. But we need 1.30 as output. is there any way to achieve this?
View 14 Replies
View Related
May 23, 2015
I have the below query
DECLARE @GivenDate DATE='2015-05-13'
create table #table (LedgerID int,AttDate Date, checkedtime time,checkedtype varchar(1))
insert into #table (LedgerID,AttDate,checkedtime,checkedtype) values (1232,'2015-05-13','09:01:48.0000000','I')
insert into #table (LedgerID,AttDate,checkedtime,checkedtype) values (1232,'2015-05-13','13:05:52.0000000','O')
insert into #table (LedgerID,AttDate,checkedtime,checkedtype) values (1232,'2015-05-13','14:10:25.0000000','I')
[code]....
the result is like below
i need 'TotalDiffernceTime' column as new column (OUT1-IN1)+(OUT2-IN2).
i am using SQLServer 2008 R2
View 8 Replies
View Related
Apr 16, 2015
I'm trying to calculate the time difference between a date field and today's date in days. The date field is not mandatory and can therefore be blank. I'm trying to execute the following query:
SELECT employee_code, Civil_ID, DATEDIFF(Day, Civil_ID, GETDATE())
FROM ODEV_VIEW_Credentials_Expiry_Dates
WHERE Civil_ID IS NOT NULL AND Civil_ID != ''
ORDER BY employee_code
I keep getting the following message:
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Warning: Null value is eliminated by an aggregate or other SET operation.
No matter what filter I use to process non-blank dates, it never works.
View 12 Replies
View Related
Jul 15, 2015
just see same kind of two sql statement
BEGIN TRAN
SELECT *
FROM authors AU
WITH (HOLDLOCK, ROWLOCK)
WHERE AU.au_id = '274-80-9391'
COMMIT TRAN
BEGIN TRANSELECT *
FROM authors AU
WITH (UPDLOCK, ROWLOCK)
WHERE AU.au_id = '274-80-9391'COMMIT TRAN
i like to know what is the difference between HOLDLOCK and UPDLOCK in sql server. explain with example to better understand.
View 4 Replies
View Related
Jun 14, 2006
Hello, I have a question on sql stored procedures.
I have such a procedure, which returnes me rows with ID-s.
Then in my asp.net page I make from that Id-s a string like
SELECT * FROM [eai.Documents] WHERE CategoryId=11 OR CategoryId=16 OR CategoryId=18.
My question is: Can I do the same in my stored procedure? (without sending it to page)
Here is it:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[eai.GetSubCategoriesById]
(
@Id int
)
AS
declare @path varchar(100);
SELECT @path=Path FROM [eai.FileCategories] WHERE Id = @Id;
SELECT Id, ParentCategoryId, Name, NumActiveAds FROM [eai.FileCategories]
WHERE Path LIKE @Path + '%'
ORDER BY Path
fileCategories table: (for information)Here is the screenshot of the table (10 kb )http://eai.w2o.ru/screen1.gif
Thank you
Artashes
View 12 Replies
View Related
Jun 9, 2015
I am trying to find a solution in order to make a pivot dynamically. One of my department charge every month all the sales figure in one table and I need to pick up the last two months archived in order to make a pivot and to see if something is changed or not. What I am trying to do is to have these last two months dynamically. create table forum (customer varchar (50), nmonth varchar(6), tot int, archived datetime)
insert into forum values ('Pepsi','201503',100,'2015-04-28'),
('Pepsi','201504',200,'2015-04-28'),
('Texaco','201503',600,'2015-04-28'),
('Texaco','201504',300,'2015-04-28'),
[code]...
As you can see I have to change manually the values underlined every months but it's a temporary solution. How can I set up the last two months in a dynamic way?
View 3 Replies
View Related
Aug 14, 2014
How would I compare 2 rows to find the difference in the columns?
Example:
ID Column1 Column2 Column3
1 Text1 Text4
2 Text1 Text2 Text3
Result:
Column1: Text2 New
Column3: Text4 Old Text3 New
View 6 Replies
View Related
Sep 28, 2007
I am trying to create an exception report that will show the difference between two versions of the same row. (Combination of two different sources in sql, with source 1 having childID = 0 and the other source having childID = 1; parentID is the link between them)
The results are as follows:
ParentID - ChildID - Col1 - Col2 - Col3
1 - 0 - AA - BB - CC
1 - 1 - AA - BF - CC
2 - 0 - GG - NN - TT
2 - 1 - DE - NN - TA
3 - 0 - etc
3 - 1 - etc
4 - etc
How can I render the differences in red in RS?
View 1 Replies
View Related
May 21, 2015
declare @siva1 datetime;
declare @siva2 datetime;
set @siva1='2014-03-10 05:02:11'
set @siva2='2014-03-12 23:52:11'
i want output like this 2.18 means 2day 18hours difference how using query
View 6 Replies
View Related
Sep 23, 2015
In sql we have a built in function
DATEDIFF(second, startdate, enddate)
How can we achieve the same using Log parser query for date time in format (2015-09-22 10:25:30.5220)
Example:
startdate = 2015-09-22 10:25:30.5220.
Enddate = 2015-09-22 10:26:30.5220
After DateDiff I need to get 6 seconds.
View 5 Replies
View Related