Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8903571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:54:08+00:00 2026-06-15T01:54:08+00:00

This is my table Create table gpscli ( cliente int,/*this is my id client*/

  • 0

This is my table

Create table gpscli
(
   cliente int,/*this is my id client*/
   inicio datetime,/*this is start time*/
   fin datetime,/this is finished time**/
   fecha datetime/*this is my date because inicio and fin could be a bad date*/
)

Table filled is something as this

select cliente, inicio, fin, fecha from gpscli order by fecha, cliente

1 '23-04-2012 10:23:51' '23-04-2012 10:26:38' '23-04-2012 00:00:000'
2 '23-04-2012 10:28:41' '23-04-2012 10:30:12' '23-04-2012 00:00:000'
3 '23-04-2012 10:33:58' '23-04-2012 10:37:24' '23-04-2012 00:00:000'
4 '23-04-2012 10:40:42' '23-04-2012 10:43:12' '23-04-2012 00:00:000'
5 '23-04-2012 10:45:46' '23-04-2012 10:57:18' '23-04-2012 00:00:000'
1 '24-04-2012 10:23:12' '24-04-2012 10:26:28' '24-04-2012 00:00:000'
2 '24-04-2012 10:23:29' '24-04-2012 10:26:58' '24-04-2012 00:00:000'
3 '24-04-2012 10:23:23' '24-04-2012 10:26:56' '24-04-2012 00:00:000'
4 '24-04-2012 10:23:12' '24-04-2012 10:26:28' '24-04-2012 00:00:000'
5 '24-04-2012 10:23:29' '24-04-2012 10:26:58' '24-04-2012 00:00:000'
1 '24-05-2012 10:23:12' '24-05-2012 10:26:28' '24-05-2012 00:00:000'
2 '24-05-2012 10:23:29' '24-05-2012 10:26:58' '24-05-2012 00:00:000'
3 '24-05-2012 10:23:23' '24-05-2012 10:26:56' '24-05-2012 00:00:000'
4 '24-05-2012 10:23:12' '24-05-2012 10:26:28' '24-05-2012 00:00:000'
5 '24-05-2012 10:23:29' '24-05-2012 10:26:58' '24-05-2012 00:00:000'

This information is saved by a user at this time would be called “supervisor”

supervisor is person which go store on store question what products client is going to want.

So he (supervisores) moves in car. When he opened a windows (in pockec pc), “inicio” is saved and when supervisor close the windows then “fin” is saved in database.

Now with this information I could get how time supervisor took with a client by mes, but I really need is, how long time supervisor took for move between client by mes.

Not client 1 is necessary the first client for one day, the first client is which has the min on inicio column. same for the last client with fin column.

How long time supervisor took for move between client by mes.

I need something as it

  • for first client transfer time is 0.
  • for second client, transfer time is inicio (this inicio column is of current) - fin (this fin is the former client)
  • for third client, transfer time is inicio (this inicio column is of current) - fin (this fin is the former client)

Finally I’ll need group by month,client

I don’t have idea how to get it (without using a loop, I wouldn’t like use it)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:54:09+00:00Added an answer on June 15, 2026 at 1:54 am

    I could solved

    create table #datos
    (
    cliente int,
    fecha datetime,
    inicio datetime,
    fin datetime,
    id int identity
    )
    
    
    insert into #datos (cliente,fecha,inicio,fin)
    select cliente,fecha,  isnull(t_inicio,'01/01/1900') inicio,isnull(t_fin,'01/01/1900') fin
    from gpscli order by  fecha, t_inicio,t_fin
    
    
    alter table #datos
    add idmas1 int
    
    update #datos set idmas1=id+1
    
    
    select d.cliente, d.fecha, d.inicio, d.fin,d.id,d2.fin fin_anterior from #datos d
    inner join #datos d2 on
    d.id=d2.idmas1
    

    now i have the finished time called as “fin_anterior” and now i can group by client, month or how it was necessary

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With this table: CREATE TABLE test_insert ( col1 INT, col2 VARCHAR(10), col3 DATE )
I have this table: CREATE TABLE `maindb`.`daily_info` ( `di_date` date NOT NULL, `di_sid` int(10)
I have this table: create table t (value int, dt date); value | dt
I have this table CREATE TABLE `codes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
I have this table: CREATE TABLE `test` ( `ID` int(11) NOT NULL auto_increment, `text`
I have this table: CREATE TABLE `point` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `siteid`
I have this table: CREATE TABLE IF NOT EXISTS `produtos` ( `id` int(11) NOT
This table is used to store sessions (events): CREATE TABLE session ( id int(11)
I have this table: CREATE TABLE perarea ( id_area INT primary key, nombre VARCHAR2(200),
I'm adding this table: CREATE TABLE contenttype ( contenttypeid INT UNSIGNED NOT NULL AUTO_INCREMENT,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.