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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Sum for Trend

Sum for Trend

Scheduled Pinned Locked Moved Database
databasehelptutorial
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
    indian143
    wrote on last edited by
    #1

    Hi All, I have a report in which, I have to show the trend values like sum for the same columns I have to show yesterday, 1week ago and 2weeks ago and 1month ago. Like for example I have 2 columns and one date column. Now I have to write a query in such a way that the sum(col1), sum(col2) for 1 day ago, 1 week ago and 1month ago in the same row. Can anybody please help me in writing this query. Any link or any code snippet will be very much helpfull. Thanks in advance.

    Thanks & Regards, Md. Abdul Aleem NIIT technologies

    M 1 Reply Last reply
    0
    • I indian143

      Hi All, I have a report in which, I have to show the trend values like sum for the same columns I have to show yesterday, 1week ago and 2weeks ago and 1month ago. Like for example I have 2 columns and one date column. Now I have to write a query in such a way that the sum(col1), sum(col2) for 1 day ago, 1 week ago and 1month ago in the same row. Can anybody please help me in writing this query. Any link or any code snippet will be very much helpfull. Thanks in advance.

      Thanks & Regards, Md. Abdul Aleem NIIT technologies

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Break it into 4 queries, 1 for each time period doing the appropriate aggregation for each query, include the common key. Then join the 4 queries into 1 using the common key. I would use table vars to hold the temp data. BTW I would not put my company name in your sig, it can be incorrectly construed (look it up).

      Never underestimate the power of human stupidity RAH

      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