How can I fill the blank space in the example below?

I have to fill using sql statement the blank space with the same description that appears below that belong to the same STTCKT. I
am using a temporary table.

There is no need in ROW_NUMBER. You can use simple query like below sample which cost 6% relative to the use of ROW_NUMBER which cost 94% (sort is havy operation with no index).
DDL+DML:
CREATE TABLE test( [STBK#] varchar(50), STTCKT int)
truncate table test
Insert into test values
(null, 48035)
,('First Two Truck', 48035)
,(null, 48039)
,('First Two Truck', 48039)
,(null, 48046)
,('First Two Truck', 48046)
,(null, 48054)
,('KLS LOGISTIC, INC.', 48054)
GO
select * from test
GO
If all you need is SELECT with FILL then check this:
select
--[STBK#] ,
STTCKT, [Fixed_STBK#]
from test T1
Cross APPLY (SELECT TOP 1 T.[STBK#] FROM test T WHERE T.STTCKT = T1.STTCKT and T.STBK# IS NOT NULL) T2 ([Fixed_STBK#])
And you can use this query as well without CROSS APPLY
select
--T1.[STBK#] ,
T1.STTCKT, T2.[Fixed_STBK#]
from test T1
LEFT JOIN (SELECT T.STTCKT,MAX(T.[STBK#]) [Fixed_STBK#] FROM test T GROUP BY T.STTCKT) T2 ON T1.STTCKT = T2.STTCKT
If you are looking for update the original table please check this:
UPDATE test
SET [STBK#] = T2.[Fixed_STBK#]
FROM test T1
Cross APPLY (SELECT TOP 1 T.[STBK#] FROM test T WHERE T.STTCKT = T1.STTCKT and T.[STBK#] IS NOT NULL) T2 ([Fixed_STBK#])
WHERE T1.[STBK#] IS NULL
GO
I hope this is helpful and answer your need, If not please try to clrify your needs and post your DDL+DML
[Personal Site] [Blog] [Facebook]

Similar Messages

  • How do I get rid of the blank space at the bottom of the new Firefox menu?

    The new firefox 4 has a different menu system. IT has blank space at the bottom wiht just a plus sign that opens new tabs. I can get that from the + sign by the tabs and don't want it or the rest of the blank space on the bar. I need all the space in the main window I can get. How do I get rid of this?
    Found my own answer, disable Conduit Engine toolbar, whatever the heck that is. Why it's enabled to start with is beyond me.

    Hi stephanie,
    These are unrelated questions/statements.
    Space before and space after a paragraph are controled in the Text Inspector, as you've found out.
    Pages will create a page break whenever there is no room for another line on the page. That break can come anywhere in a paragraph.
    You may be thinking of Widow and Orphan prevention, and the other Pagination controls, found under the More button in the Text Inspector. (If that's what you found, then thanks for the refresher! I hadn't been to that pane for awhile, and had forgotten the variety of pagination controls available.
    Regards,
    Barry

  • How can I fill in a form, save the form such that it cannot be further altered, and email it as it was saved?

    How can I fill in a form, save the form such that it cannot be further altered, and email it as it was saved?  I created a form with 5 fields.  It is a form letter that is intended as a receipt for funds received.  I want to fill in the date, name, amount received, etc., save the form with inserted data fields so they can't be further altered, and be able to email it as a complete unalterable PDF document.  What I'm doing now, is filling in the fields, printing it, scanning it, and emailing it as an unalterable document.  The document was created on a Mac using Adobe Acrobat Pro version 10.1.13.  The document is filled in on a PC that only has Adobe reader on it, printed, scanned and emailed as an attachment. There must be a better way! 

    If you have access to a ASP.net Web Server, then the submission could be FLATTENED with FDFToolkit.net and emailed without client-side email software by only using Adobe Reader.
    For more information check out the following websites:
    http://www.pdfemail.net/examples/
    http://www.fdftoolkit.net/examples/

  • How do I delete the blank space at the beginning or end of a project?

    I constantly end up with blank space at the beginning or end of a project - how do I remove it?  I get this ALL the time and I jsut can't get rid of it.  Obviously I want my project to start at 0.00 not at 1.xx.
    Thanks.

    That's not a project. You're inside an multicam angle editor. You need to edit the multicam clip into a project. That's where you edit it.

  • After making a live recording, how does one delete the blank space at the end?

    I have asked everyone I know and no one seems to know how to do this. Thanks, for any info!

    Do you want:
    A) Remove the blank space in your GarageBand Project
    B) Remove the silence in the actual audio file
    Just make sure that you are aware of the difference between an Audio Region and an Audio File
    About A)
    Just resize the right border of the Audio Region. The Audio Region is just a reference to the actual Audio File on your drive. This solution is just for editing your Project it won't get rid of any silence int he actual Audio File
    About B)
    You cannot do that in GarageBand itself. GarageBand only allows editing of the Audio Region (non-destructive editing) not the actual Audio File (destructive editing). A quick way to do it is open the file in QuickTime, crop it and save it.
    Hope that helps
    Edgar Rothermich
    http://DingDingMusic.com/Manuals/
    'I may receive some form of compensation, financial or otherwise, from my recommendation or link.'

  • How can I create an internal space from the border in every cell in a table?

    How can I create an space between the text contents and the border inside in every cell in a table in Pages?

    Change the Inset margin in the Inspector palette > T tab > Text

  • How can I get consecutive blank spaces in a PDF?

    Native file is built in InDesign CS6.
    I have 2 fixed-width spaces within a part number. When I export to a PDF and open in Acrobat it is reading it as one space.
    i.e.  Dealer opens PDF to copy part number and paste into a Word document. Part number has a two-digit variable number but it's only reading as a single space in the PDF.
    Any ideas or suggestions?

    PDF is not a good format for the storage and exact retrieval of textual information. A key reason is that frequently there are no spaces in PDF, just a horizontal gap whose interpretation is in the eye of the viewer. Tagging the PDF from InDesign might help.

  • What is with all the blank space on the sides of the browser?

    Well, I was forced into Firefox 9, and 1/4 of the screen on the right, and 1/4 on the left, is blank white space. Why would that happen? Plus, I have to change the zoom everytime I load a new page.
    Can anyone help? Using Win7 on a laptop with a display at 1920 x 1080.

    You can use an extension to set a default font size and page zoom on web pages.
    *Default FullZoom Level: https://addons.mozilla.org/firefox/addon/default-fullzoom-level/

  • How to Remove Blank spaces in the text elements for a smartform

    Hi All,
    Can any one please help me out to remove the blank spaces in the text elements.
    We are printing Labels using the Zebra Printer and we have rotated the windows to 90 degrees.
    We are able to see out text and barcodes. But the issues is when we are printing the label. We are getting spaces in the Text and in the Text elements fields. I have tried to give &g_name(C)&. But it is not working even i worked with style sheet spaces no luck.
    Currently out text and fields are printing like this
    s h r i y a n
    material number
    1111  -001  -000
    They should print like
    shriyan
    1111-001-000
    According to the ZEBRA suggestions we are using the font helve.
    Plase help us it is very urgent.
    Reward point will be given.
    Thanks

    Hi,
    Just use Condense g_name inside the program lines.
    Just to see how it behaves put a hard breakpoint.
    Break Username. and check the condense statement.
    condense <your field> no-gaps.
    Create program lines ahead of printing. give the field you want to condense in the input and output parameters of the program lines.
    Use condense inside the program lines.
    Thanks,
    Vamshi.

  • How can i copy a blank form and add it to the original?

    How can I copy a blank page of a form and add it to the original?

    So, if I want to fill in blanks on a form where I need to add more pages to fill history, what program do I need? In Adobe Reader, I can edit and fill in blanks, but I cannot duplicate more blank pages.

  • How do I get rid of the blank space after one paragraph and before the next paragraph startsin Pages '09?  I understand that I should not have a page break mid paragraph but that is what I want.

    How do I get rid of the blank space after one paragraph and before the next paragraph startsin Pages '09?  I understand that I should not have a page break mid paragraph but that is what I want.

    Hi stephanie,
    These are unrelated questions/statements.
    Space before and space after a paragraph are controled in the Text Inspector, as you've found out.
    Pages will create a page break whenever there is no room for another line on the page. That break can come anywhere in a paragraph.
    You may be thinking of Widow and Orphan prevention, and the other Pagination controls, found under the More button in the Text Inspector. (If that's what you found, then thanks for the refresher! I hadn't been to that pane for awhile, and had forgotten the variety of pagination controls available.
    Regards,
    Barry

  • My Firefox is not working. (All I get is a blank white screen with the Fireox logo). If I have to reinstall firefox 3.66, how can I transfer my old profile to the new installation?

    My Firefox is not working (All I get is a blank white screen with the firefox logo. If I have to reinstall Firefox 3.66, how can I transfer my old profile to the new installation?
    == This happened ==
    Every time Firefox opened

    David.  Thank you very much.   The problem was not with the canvas but rather the Viewer.  But the solution was the same.  Somehow, the Viewer window was re-set to Alpha.  I changed it back to RGB.... and the picture is back.   These issues are often very simple.... but they can drive you bats if you don't know the answer.   Very grateful.  Tim

  • I bought 3 iPhone 4s and each should have 5gb of cloud. I want to only use my one iTunes ID. How can I get this storage space increased to the 15 GB?

    I bought 3 iPhone 4s and each should have 5gb of cloud. I want to only use my one iTunes ID. How can I get this storage space increased to the 15 GB?

    iCloud storage is not allocated by device. iCloud storage is allocated to your iCloud AppleID. You get 5GB of iCloud storage.

  • How do I clear the blank space between content and footer?

    In the process of revising a Muse website, I deleted some content from one of the pages and revised the content that remained on the page. Now I have a blank area between the bottom of the revised content and the top of the footer, and I can't seem to get rid of the blank space. It doesn't appear that there are any text blocks or other images in that area, so I can't find any objects to delete. Help?
    The website is currently published in a draft mode for client review. You can examine it at: http://page7creative.com/clients/coremove_jun2012draft/retreats.html. The page in question is the Retreats page. Restarting Muse made no difference. I work on the Mac platform.
    Before I sent this post, I decided to try creating a new page, then copy/paste the content onto the new page, and save the Muse site under a different name. Lo and behold, the page (and the site) works like it should...without any extra space above the footer on that page. It would appear that something went astray when I deleted content on that page. I can use the new page to get the site working properly, but decided to go ahead and send this post so that you can look at the page code and perhaps see what is wrong that is causing the blank space...in case I ever run into this again.
    Thank you.
    pyxis83

    Thanks for sending your file.
    There is a graphic at the bottom of the content area of the Retreats page that's been cropped to a size of zero width and 2 pixels in width.
    Unfortunately, there's a bug with pointer tool drag selection (aka marque selection) that prevents it from selecting an item that has zero width or zero height. Therefore the easiest way to select this item to delete it is to select any other item on the page, then hit the tab key repeatedly to cycle through every item on the page. When you get to this item you should see a little pile of selection handles at the left edge of the third column and right at the bottom of the content area. The width and height will display as zero and 2. Delete this item and the page will resize to fit the remaining content.

  • How can I view a completed form as the person filling it out sees it

    How can I view a completed form as the person filling it out sees it. The text that is a part of the form does not print when the record(from) is printed.

    We now support saving a response from the View Responses tab to PDF (that retains the form design shown on the Design tab). The PDF can be shared, archived or printed using Adobe Reader.
    You can read more about it here: http://forums.adobe.com/thread/1085672
    Please try it out and give us your feedback.
    Randy

Maybe you are looking for

  • Variable not being included in XML data file output

    This seems like it should be obvious, but I've struggled with this for a couple of days. As a programming principle, I like to make the form as "smart" as possible and the resulting Word templates, or XML documents as simple as possible. I need to be

  • "Does Bridge come with Photoshop if I buy the CC single app?"

    Question from a Customer-"Does Bridge come with Photoshop if I buy the CC single app?"

  • Logic needed urgent

    Hi Friends, I need logic (code for the following requirement. 1. Bank guarantees received are entered by F-57 transaction as a noted item in system and the following data will be captured in the respective field. Document date: Bank Guarantee date Po

  • RegEx for characters with accents and such but not alphanum or punctuation

    I'm creating a fuction that checks for the following code snip. I'm having trouble understanding what I need to do to get the last criteria. How do I specifically check for characters with additional marks  such as   a'   but  not  a Thanks in advanc

  • Data storage for the T.codes

    hi , sap experts , If we maintain the data for the following t.code's in which tables the data will be stored: T.codes po13 ppoc_old ppoce ppsc Thanks in advance