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. Stock report

Stock report

Scheduled Pinned Locked Moved Database
questionhelptutorial
7 Posts 3 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.
  • A Offline
    A Offline
    adyck
    wrote on last edited by
    #1

    Hello Forum! Here is my problem: I have a table called TblArticle (artnr, comment) and a table called TblArticlemoves (autoid, artnr, quantity, date). Now I need a report that looks like the following example: artnr ....|01.11.07 | 02.11.07 | 03.11.07 | 04.11.07 | 05.11.07 | ... A ........| 20 ........| 20 .........| 35.......... | 45 ........| .........15 | ... B........ | 5 ..........| 15......... |.25 ..........| 5 ......... | ..........20 | ... . . . The main thing is I need to display each day of a month, but I 'm not having an entry for each day of a month in my table TblArticlemoves. Therefore i need to calculate the stock quantity for each day of the month. How can i do this? regards adyck

    P S 2 Replies Last reply
    0
    • A adyck

      Hello Forum! Here is my problem: I have a table called TblArticle (artnr, comment) and a table called TblArticlemoves (autoid, artnr, quantity, date). Now I need a report that looks like the following example: artnr ....|01.11.07 | 02.11.07 | 03.11.07 | 04.11.07 | 05.11.07 | ... A ........| 20 ........| 20 .........| 35.......... | 45 ........| .........15 | ... B........ | 5 ..........| 15......... |.25 ..........| 5 ......... | ..........20 | ... . . . The main thing is I need to display each day of a month, but I 'm not having an entry for each day of a month in my table TblArticlemoves. Therefore i need to calculate the stock quantity for each day of the month. How can i do this? regards adyck

      P Offline
      P Offline
      Prateek G
      wrote on last edited by
      #2

      you can loop through all the days of months and store count of moves in another table.

      P 1 Reply Last reply
      0
      • A adyck

        Hello Forum! Here is my problem: I have a table called TblArticle (artnr, comment) and a table called TblArticlemoves (autoid, artnr, quantity, date). Now I need a report that looks like the following example: artnr ....|01.11.07 | 02.11.07 | 03.11.07 | 04.11.07 | 05.11.07 | ... A ........| 20 ........| 20 .........| 35.......... | 45 ........| .........15 | ... B........ | 5 ..........| 15......... |.25 ..........| 5 ......... | ..........20 | ... . . . The main thing is I need to display each day of a month, but I 'm not having an entry for each day of a month in my table TblArticlemoves. Therefore i need to calculate the stock quantity for each day of the month. How can i do this? regards adyck

        S Offline
        S Offline
        SimulationofSai
        wrote on last edited by
        #3

        Doing this with straightforward SQL might get messy and complex. If you're up to it, create a temp table, fill in the days of the month and the stock value and PIVOT it to form the report.

        SG Cause is effect concealed. Effect is cause revealed.

        A 1 Reply Last reply
        0
        • P Prateek G

          you can loop through all the days of months and store count of moves in another table.

          P Offline
          P Offline
          Prateek G
          wrote on last edited by
          #4

          u can create a proc with following steps which will return a table.. 1) Get no. of days in month. say @no and @p = 1 2) while (@p < @no) 3) Get date and write query GetDate[^] 4> create table with date and count and return it. Lemme know if it is useful...

          A 1 Reply Last reply
          0
          • P Prateek G

            u can create a proc with following steps which will return a table.. 1) Get no. of days in month. say @no and @p = 1 2) while (@p < @no) 3) Get date and write query GetDate[^] 4> create table with date and count and return it. Lemme know if it is useful...

            A Offline
            A Offline
            adyck
            wrote on last edited by
            #5

            Hello Prateek G, excuse me, I'm a beginner but 1)what do you mean with @p? 3)can You give me some more hints 4)do You mean selecting the count from TblArticlemoves into a Date table? Thank You! Regards adyck

            1 Reply Last reply
            0
            • S SimulationofSai

              Doing this with straightforward SQL might get messy and complex. If you're up to it, create a temp table, fill in the days of the month and the stock value and PIVOT it to form the report.

              SG Cause is effect concealed. Effect is cause revealed.

              A Offline
              A Offline
              adyck
              wrote on last edited by
              #6

              Hi SG, I've managed to create a temp table like this: Dim dt As DataTable = New DataTable("TblDate") dt.Columns.Add("artnr", Type.GetType("System.String")) Do While startDate < endDate dt.Columns.Add((startDate), Type.GetType("System.String")) startDate = startDate.AddDays(1) Loop Now, how do fill in the stock values into the TblDate? Regards adyck

              S 1 Reply Last reply
              0
              • A adyck

                Hi SG, I've managed to create a temp table like this: Dim dt As DataTable = New DataTable("TblDate") dt.Columns.Add("artnr", Type.GetType("System.String")) Do While startDate < endDate dt.Columns.Add((startDate), Type.GetType("System.String")) startDate = startDate.AddDays(1) Loop Now, how do fill in the stock values into the TblDate? Regards adyck

                S Offline
                S Offline
                SimulationofSai
                wrote on last edited by
                #7

                I meant a Temp table in SQL Server. Instead of creating a tables with dates as columns, you can use the PIVOT command to prepare your report. PIVOT [^]is easy to master. Just look it up.

                SG Cause is effect concealed. Effect is cause revealed.

                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