Solved

SQL Question

Posted on 2016-08-04
1
28 Views
Last Modified: 2016-08-04
I'm trying to figure out this query for SQL Server

My table has records that are inserted as follows

note      process               start              stop
note1      myprocess       8/4/2016      
note1      myprocess                            8/5/2016


I want to group the two records on Note and Process and return a date difference between Start and Stop

Returned

Note               Process            DateTimeDiff
note1              myprocess      1


help?
0
Comment
Question by:keschuster
1 Comment
 
LVL 32

Accepted Solution

by:
ste5an earned 500 total points
ID: 41743439
Rows, not records. Any chance to change your data loading?

Otherwise it is a simple GROUP BY:

SELECT  Note, 
        Process, 
        Min(Start), 
        Max(Stop), 
        DATEDIFF(DAY,Min(Start), Max(Stop))
FROM yourTable
GROUP BY Note, Process;

Open in new window

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now