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 SP

SQL SP

Scheduled Pinned Locked Moved Database
databasesharepointquestioncareer
6 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.
  • C Offline
    C Offline
    Care Career
    wrote on last edited by
    #1

    Hi My Stored Procedure output is as below given. Interval Avg1 Avg2 NULL NULL NULL 04/08 NULL NULL 05/08 2000 NULL NULL 1000 NULL NULL NULL NULL NULL NULL 4000 NULL NULL 3000 I want result in two rows as below given. Interval Avg1 Avg2 04/2008 2000 4000 05/2008 1000 3000 Please let me know how i can do this using temm table ? Thanks Care Career

    W N 2 Replies Last reply
    0
    • C Care Career

      Hi My Stored Procedure output is as below given. Interval Avg1 Avg2 NULL NULL NULL 04/08 NULL NULL 05/08 2000 NULL NULL 1000 NULL NULL NULL NULL NULL NULL 4000 NULL NULL 3000 I want result in two rows as below given. Interval Avg1 Avg2 04/2008 2000 4000 05/2008 1000 3000 Please let me know how i can do this using temm table ? Thanks Care Career

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Based on the info you posted, the only thing I can imagine is that you should modify the output from sp to give you what want. So, you need to include to the post, how the result is made in sp and what do you want to change or if you cannot change the sp, what is the logic you want to achieve with temp tables (why 04/2008 has 4000 in avg2, since there is nothing in the data combining the row "NULL NULL 4000" to the row "04/08 NULL NULL" Mika

      The need to optimize rises from a bad design

      C 2 Replies Last reply
      0
      • W Wendelius

        Based on the info you posted, the only thing I can imagine is that you should modify the output from sp to give you what want. So, you need to include to the post, how the result is made in sp and what do you want to change or if you cannot change the sp, what is the logic you want to achieve with temp tables (why 04/2008 has 4000 in avg2, since there is nothing in the data combining the row "NULL NULL 4000" to the row "04/08 NULL NULL" Mika

        The need to optimize rises from a bad design

        C Offline
        C Offline
        Care Career
        wrote on last edited by
        #3

        Hi I do not want to change my existing SP I just want output as below given.I want to remove NULL Please help.. Sr No Interval Avg1 Avg2 1 04/2008 2000 4000 2 05/2008 1000 3000

        W 1 Reply Last reply
        0
        • W Wendelius

          Based on the info you posted, the only thing I can imagine is that you should modify the output from sp to give you what want. So, you need to include to the post, how the result is made in sp and what do you want to change or if you cannot change the sp, what is the logic you want to achieve with temp tables (why 04/2008 has 4000 in avg2, since there is nothing in the data combining the row "NULL NULL 4000" to the row "04/08 NULL NULL" Mika

          The need to optimize rises from a bad design

          C Offline
          C Offline
          Care Career
          wrote on last edited by
          #4

          I want to remove NULL from below given resultset.If I will remove NULL then data will come in two rows.SO how Can i do this using temp table? please help its urgent. Interval Avg1 Avg2 NULL NULL NULL 04/08 NULL NULL 05/08 2000 NULL NULL 1000 NULL NULL NULL NULL NULL NULL 4000 NULL NULL 3000 Thanks Care Career

          1 Reply Last reply
          0
          • C Care Career

            Hi My Stored Procedure output is as below given. Interval Avg1 Avg2 NULL NULL NULL 04/08 NULL NULL 05/08 2000 NULL NULL 1000 NULL NULL NULL NULL NULL NULL 4000 NULL NULL 3000 I want result in two rows as below given. Interval Avg1 Avg2 04/2008 2000 4000 05/2008 1000 3000 Please let me know how i can do this using temm table ? Thanks Care Career

            N Offline
            N Offline
            nelsonpaixao
            wrote on last edited by
            #5

            listen, first i assume columns are varchar,int,int type if column is varchar type you can use isnull() funtion like this:

            select,...,isnull(avg1,'') FROM mytable

            that way you will get an empty slot. if you want to erase all row with null values type

            select * from mytable where (interval <> null) and (avg1 <> null) and (avg2 <> null)

            what you type is wrong, you can´t get that, columns not from the same row!!! about temp table forget it, you don´t need that ... for now :omg:

            nelsonpaixao@yahoo.com.br trying to help & get help

            1 Reply Last reply
            0
            • C Care Career

              Hi I do not want to change my existing SP I just want output as below given.I want to remove NULL Please help.. Sr No Interval Avg1 Avg2 1 04/2008 2000 4000 2 05/2008 1000 3000

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              This simply isn't possible unless there is some kind of logic why the result set should look like you described. If your result set in the start is:

              Interval Avg1 Avg2
              NULL NULL NULL
              04/08 NULL NULL
              05/08 2000 NULL
              NULL 1000 NULL
              NULL NULL NULL
              NULL NULL 4000
              NULL NULL 3000

              and you want:

              Interval Avg1 Avg2
              04/2008 2000 4000
              05/2008 1000 3000

              Please explain for example why the last row having 3000 in Avg2 should be combined with the row having 05/08 as interval. Also why the value 2000 on the same row is moved to the row 04/08 and so on... One crucial thing is that you think this as result sets having rows with conditions since this is the way the DBMS does it.

              The need to optimize rises from a bad design

              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