?
Solved

select if null fill in row

Posted on 2010-09-08
12
Medium Priority
?
508 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:Seven price
  • 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:Seven price
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:Seven price
ID: 33628286
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 70

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:Seven price
ID: 33628426
no but I can use a select count(*)
0
 
LVL 9

Author Comment

by:Seven price
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:Seven price
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 70

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:Seven price
ID: 33693923
>>ORDER BY column(s) need to be known
??
0
 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 1500 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:Seven price
ID: 33720150
t
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

850 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