Solved

select if null fill in row

Posted on 2010-09-08
12
484 Views
Last Modified: 2012-08-13
I have a ms-sql table I need to fill in the column with the repeated column value, for example
Any value thats null I would like it to repeat.


ScreenHunter-01-Sep.-08-10.21.gif
0
Comment
Question by:sevensnake77
  • 7
  • 3
  • 2
12 Comments
 
LVL 16

Expert Comment

by:vdr1620
ID: 33627513
can you post a sample of your expected output??
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 33627778
example from the photo is see cComments
if null then printing will fill everything above with the same line.

where dTotal 1023.96 will fill in the null under 50.67 until it reaches anything not null.

0
 
LVL 9

Author Comment

by:sevensnake77
ID: 33628286
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 33628352
Do you have an identity column?  Or another sequence key?  The data must be sequenced to do what you are trying to do.
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 33628426
no but I can use a select count(*)
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 33628580
WRITE QUERY TO REPEAT VALUE OF PREVIOUS RECORD >>
do you have example?? in a select statement not update
0
 
LVL 16

Expert Comment

by:vdr1620
ID: 33628620
are you using any order by clause ...how do you know what your result set will be

4.13  50.67  NULL
NULL NULL  Printing.......

OR

NULL NULL  Printing.......
4.13  50.67  NULL

The Order makes a lot of difference.. Count(*) will not solve the problem..

Also,What would your output be if there are 3 rows like below

1          3      Row1
NULL NULL NULL
2          4        Row3
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 33628684
I am using a order by clause of course, there will never by 3 null rows, i just need the syntax if you can.

thanks
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 33628715
To produce the right code, the ORDER BY column(s) need to be known.
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 33693923
>>ORDER BY column(s) need to be known
??
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 500 total points
ID: 33696824
>> I am using a order by clause of course <<
>> To produce the right code, the ORDER BY column(s) need to be known. <<
>> >>ORDER BY column(s) need to be known
??<<


What are the names of the ORDER BY column(s)????

There is NO way to write code for this w/o knowing what the ORDER BY columns are!!
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 33720150
t
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
I have a large data set and a SSIS package. How can I load this file in multi threading?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question