Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Calculation...

SQL Calculation...

Scheduled Pinned Locked Moved Database
databasehelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Illegal Operation
    wrote on last edited by
    #1

    Hi, Can someone please advise me on what to do with this issue. I have a table that has a DATE, GROSSHOURS, GROSSMINUTES and TOTAL. I have a select query that takes the GROSSHOURS and GROSSMINUTES and add them together in seconds e.g: 1H 30M = 90M My issue is this: I have 2 lines on the same day. 2010/01/05 1HOUR 30MINUTES 90MINUTES 2010/01/05 2HOURS 20MINUTES 140MINUTES How will I write a select statement where I can only display 1 line for 2010/01/05 but with both totals? 2010/01/05 230MINUTES My statement looks like this at the moment:

    Select Id, CONVERT(VARCHAR,EntryDate,111) AS EntryDate, GrossHours, GrossMinutes, DATEDIFF(minute, StartJob, EndJob) / 60 * 60 + GrossMinutes AS Total FROM [Timesheet] GROUP BY Id, EntryDate, GrossHours, GrossMinutes, StartJob, EndJob

    Thank you!

    Illegal Operation

    _ 1 Reply Last reply
    0
    • I Illegal Operation

      Hi, Can someone please advise me on what to do with this issue. I have a table that has a DATE, GROSSHOURS, GROSSMINUTES and TOTAL. I have a select query that takes the GROSSHOURS and GROSSMINUTES and add them together in seconds e.g: 1H 30M = 90M My issue is this: I have 2 lines on the same day. 2010/01/05 1HOUR 30MINUTES 90MINUTES 2010/01/05 2HOURS 20MINUTES 140MINUTES How will I write a select statement where I can only display 1 line for 2010/01/05 but with both totals? 2010/01/05 230MINUTES My statement looks like this at the moment:

      Select Id, CONVERT(VARCHAR,EntryDate,111) AS EntryDate, GrossHours, GrossMinutes, DATEDIFF(minute, StartJob, EndJob) / 60 * 60 + GrossMinutes AS Total FROM [Timesheet] GROUP BY Id, EntryDate, GrossHours, GrossMinutes, StartJob, EndJob

      Thank you!

      Illegal Operation

      _ Offline
      _ Offline
      _Damian S_
      wrote on last edited by
      #2

      You need to remove GrossHours and GrossMinutes from your select statement and group by.

      I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups