Solved

select if null fill in row

Posted on 2010-09-08
12
464 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

747 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

11 Experts available now in Live!

Get 1:1 Help Now