Solved

getting a start date and end date from different rows MySQL

Posted on 2014-09-22
2
470 Views
Last Modified: 2014-09-22
I have a query, in that query I get the start time and a toolnumber
DROP TABLE IF EXISTS precont;
CREATE TABLE precont AS (
SELECT UploadTime as 'StartTime', ToolNumber
FROM ToolAssemblies
WHERE ControllerSn = 1024);

Open in new window

What I want is to take this:(the query above)
preresultAnd make this:(start date is the first date and the enddate is the firstdate of the next record with a new tool number
result
0
Comment
Question by:r3nder
2 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 500 total points
ID: 40337960
Hello,

try this:

select toolNumber, min(uploadtime) as startdate, max(uploadtime) as enddate

from precont

group by toolNumber
0
 
LVL 6

Author Closing Comment

by:r3nder
ID: 40338029
Thanks Samo
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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 …
Creating and Managing Databases with phpMyAdmin in cPanel.
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 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

13 Experts available now in Live!

Get 1:1 Help Now