Solved

select if null fill in row

Posted on 2010-09-08
12
473 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
 
LVL 69

Expert Comment

by:ScottPletcher
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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:ScottPletcher
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:
ScottPletcher 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

947 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now