How to specifically sort the data in a database using c#?

H!,
I have a problem in c# that require sorting of names of students in a sql database and i want it to be specific, i used data grid view to view the data of the students as shown below:
Students First Name:
Ann
Antoinette
Brenda
Judith
Lester
Santos
Suzie
Tim
if i type in a letter or abbreviation @ a textbox1 for example "s", all Names that starts with letter s will be sorted first so the output now of the query will become:
Students First Name:
Santos
Suzie
Ann
Antoinette
Brenda
Judith
Lester
Tim
So if i type j, all that starts with j will be first, and so on.
I need help for this problem coz it is so hard for me to output the students with this kind of sorting and is there a code or query string related to this problem?
thanks in advance.
Hardz

Hi,
One way is to write a query as shown below:
declare @char nvarchar(1)
select @char = 'S'
Declare @t table(name nvarchar(max))
insert into @t
values
('Santos'),
('Suzie'),
('Ann'),
('Antoinette'),
('Brenda'),
('Judith'),
('Lester'),
('Tim')
select name
from @t
where RIGHT(name,1) like @char
union all
select name
from
(select top 100 percent name
from @t
where RIGHT(name,1) not like @char
order by name) a
Hope this helps. 
-Chintak

Similar Messages

  • How do I sort the data in the spreadsheet?

    This is a fairly basic question and something I do all the time.  I need to sort the data on a particular column or set of columns and am frustrated that it is this difficult to find.  In trying to figure this out I know also have a chart on my spreadsheet that I can't seem to delete. 

    If you don't see a gray bar above the table, then tap a cell to show the gray bar.
    Select a column by tapping the gray bar directly above the column. After the column is selected, tap the exact same spot again to show a menu.
    In the menu, tap on Sort... etc...
    Sort will sort the selected column, but will also update the entire table accordingly. If you don't want the rest of the table to update, then you have to copy that column (with the columns that you do want to update) and paste them onto the canvas so they appear in their own table. Sort the column then and paste it back into the original table.
    Delete the chart from a menu that appears similarly as Sort. Tap on the chart one time to select it. Tap it again to show the menu with Delete. If you are doing this and choosing Delete, but the chart is not disappearing, then there might be a problem with the file.

  • How to retrieve all the data from a BLOB using view-generated accessor

    I am using JDeveveloper 10g v. 10.1.3 and am storing an image in a database as a blob object and need to retrieve all of the data to get the entire image and store it in an ImageIcon. The code I have works partially in that it retrieves the correct data, but only gets a piece of it, leaving me with a partial image.
    AppModuleImpl am;
    ImageVwViewImpl vo;
    am = (AppModuleImpl)panelBinding.getDataControl().getDataProvider();
    vo = (ImageVwViewImpl)am.findViewObject("ImageVwView");
    ImageVwViewRowImpl ivo = (ImageVwViewRowImpl)vo.getCurrentRow();
    ImageIcon icon = new ImageIcon(ivo.getImage().getBytes(1, (int)ivo.getImage().getBufferSize()));
    jULabel1.setIcon(icon);I either need to know how to use a stream to get the data out (from BlobDomain method getBinaryStream()), or how to get the other chunks of data separately.
    edit: I know the problem is that getBufferSize() returns an int which is too small to hold all the data, but need to know what to use instead. Thanks!

    This is the code I'm using now. Same problem :(
    AppModuleImpl am;
            ImageVwViewImpl vo;
            am = (AppModuleImpl)panelBinding.getDataControl().getDataProvider();
            vo = (ImageVwViewImpl)am.findViewObject("ImageVwView");
            ImageVwViewRowImpl ivo = (ImageVwViewRowImpl)vo.getCurrentRow();  
            ImageIcon icon = new ImageIcon(ivo.getImage().toByteArray());
            jULabel1.setIcon(icon);

  • How I load all the data in a database table into a cache?

    Hi
    Lets assume I have a lookup table I want to load it upfront into the cache so that the application can use this data from cache. One way is to write code to create a map from the database and call putALL. Is there any better approach to this?
    Another thing is if the data is more than 1 GB and if I construct a map of one GB before putting it into the cache the JVM might crash. The question is how do I distribute upront loading of the cache to multiple JVMs. Do I have to use invocation service or is there any thing out of box.

    I only use one JVMs and I use a distributed cache, the configuration XML file like this:
    <p> <distributed-scheme>
    <scheme-name>default-distributed</scheme-name>
    <service-name>DistributedCachestore</service-name>
    <backing-map-scheme>
    <read-write-backing-map-scheme>
    <scheme-ref>example-read-write</scheme-ref>
    </read-write-backing-map-scheme>
    </backing-map-scheme>
         <listener-scheme> </listener-scheme> 
         <autostart>true</autostart>
    </distributed-scheme>
    <read-write-backing-map-scheme>
    <scheme-name>example-read-write</scheme-name>
    <internal-cache-scheme>
    <local-scheme>
    <scheme-ref>default-eviction</scheme-ref>
    <high-units>50050</high-units>
    <low-units>40000</low-units>
    <expiry-delay>3600</expiry-delay> 
    </local-scheme>
    </internal-cache-scheme>
    <cachestore-scheme>
    <class-scheme>
    <scheme-ref>example-cachestore</scheme-ref>
    </class-scheme>
    </cachestore-scheme>
    <read-only>false</read-only>
    <write-delay-seconds>0</write-delay-seconds>
    </read-write-backing-map-scheme>
    <!-- 
    CacheStore test definition 
    -->
    <class-scheme>
    <scheme-name>example-cachestore</scheme-name>
    <class-name>com.tangosol.examples.coherence.DBCrudStore</class-name>
    <init-params>
    <init-param>
    <param-type>java.lang.String</param-type>
    <param-value>cachec</param-value>
    </init-param>
    </init-params>
    </class-scheme></p>
    The data in my table will reach about 1000000+ and I want to load about 50000 into cache.
    Thanks.

  • How can I set the date of my PC using Java?

    Which class has the function to set system date and time.
    Thanks in advance.

    but the following sentence
    Process p=Runtime.getRuntime().exec("date
    11-03-2002");
    always throw IOExecption error
    java.io.IOException: CreatePreocess:date 11-03-2002
    error=0
    and why?
    How to settle it?
    'date' is an internal command which means you need a shell to run it. Depending on the OS this will either be 'cmd' or 'command'. If you search the forums with the following keywords you will find examples on how to use this: "exec", "Runtime", "cmd" or "command"

  • How could I Encrypt the data of SDO_GEOMETRY type using DBMS_CRYPTO package

    Hi:
    I want to Encrypt the data of SDO_GEOMETRY object type using DBMS_CRYPTO package.
    What could I do? hope anyone can help me,give me a suggestions!
    thanks in advance.
    lgs

    well, the spatial api would not be able to handle this data anymore, so what you are trying to do is converting an SDO_GEOMETRY to some cryptable user type (see http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_crypto.htm#sthref1506) and encrypting this.
    Before using the SDO_GEOMETRY type will have to decrypt and reconvert it again and pass it to the spatial query or function.

  • How do I access the data saved on my time capsule?  for example, if i try to view my photos it tells me that i have 2.4gb of photos and gives me the option to "view with iPhoto"....but when i click on "view with iPhoto" nothing happens...  thanks!

    how do i access the data stored on my time capsule?  for example, if i try to view a photo, i get the option to "view with iphoto" but when i click on "view with iphoto" nothing happens.  i'm having similar trouble openning up movies, music, etc.  it appears as though the files exist / saved on the time capsule (because i can see how much storage they consume), but i can't open them.  thanks!

    Unfortunately, Apple removed the feature to "browse backups" in Time Machine backups of iPhoto a few years ago.
    You have to restore the entire iPhoto library to a separate location to be able to "see" it, and then choose the specific images that you want use.
    For complete details, see #15 in Pondini's excellent support document Time Machine -- FAQ.  Check the information in the pink box there.
    Frequently Asked Questions

  • How can I sort the words in a document into an alphabetical list?

    How can I sort the words in a document into an alphabetical list? Thanks!

    writer888 wrote:
    How can I sort the words in a document into an alphabetical list? Thanks!
    Copy the words to the Mac's clipboard (Edit menu> Copy)
    Paste into TextEdit 
    Next open the Edit > Find > Find window in Text Edit.
    Highlight a space between two words and Edit menu > copy, paste into the Find field
    Next create a return in the middle of your text and copy that and paste into the Replace field
    Click Replace All.
    Now Edit > Select All and Edit > Copy
    Open a Spreadsheet program with Sort ability and paste into the second column cell from the top
    place a "a" into the top column cell, select the entire colum
    Sort desending order
    Now if you need it out of spreadsheet format, then your going to need to copy just the data cells (not the entire column to avoid problems) and Paste "Special" as unformatted text into a word processing program
    If you need to get rid of the Returns, do the opposite you did in Text Edit, replace the Returns with Spaces
    A chore, but it's rare one needs to sort words into alaphabetical order.
    FYI, I used TextEdit and the free LibreOffice (Spreadsheet and Word Processing) for the above effects.

  • How can I log the data transmission of my switch in a file to analyze the quality of my communication channel?

    How can I log the data transmission of my switch in a file to analyze the quality of my communication channels?

    A lot depends on what type of switch you have and what kind of communication channels you're asking about.
    There are several Cisco tools (e.g., "ip sla", SNMP-queried values, show commands etc.) that can give useful information.
    If you give us some more information we can help more specifically.

  • How do you set the date & prevent auto revert to current date?

    Numbers 3.2.  Macbook  OS 10.9.3
    I want to set a block of cells to a particular date (05/10/14) and then add in different times.  But everytime I make a change to the default time (12:00 AM) in a specific cell, the date I initially set reverts back to the current date (05/29/14).
    How can I prevent or work around this annoying date change issue?  Thank you for any helpful tips you can provide.
    Kind regards,
    David.

    Hello
    I'd create separate columns for date and time input (formatted as text) and calculate date-time value in the third column. Something like this.
    Table definitions are as follows.
    A1    date (text)
    A2    2014-05-10
    A3    2014-05-10
    A4    2014-05-10
    A5    2014-05-10
    A6    2014-05-10
    A7    2014-05-10
    B1    time (text)
    B2    09:10
    B3    10:20
    B4    11:22
    B5    12:20
    B6    13:00
    B7    14:00
    C1     date-time
    C2    =DATEVALUE(A2)+TIMEVALUE(B2)
    C3    =DATEVALUE(A3)+TIMEVALUE(B3)
    C4    =DATEVALUE(A4)+TIMEVALUE(B4)
    C5    =DATEVALUE(A5)+TIMEVALUE(B5)
    C6    =DATEVALUE(A6)+TIMEVALUE(B6)
    C7    =DATEVALUE(A7)+TIMEVALUE(B7)
    This way, there's no implicit interpretations on date and time input.
    * The point is to format columns A and B as text.
    Hope this may help,
    H

  • How can I sort the Pictures in an Album by Name?

    I am updated my Photo App on OSX 10.10.2. All my Albums are imported fine, but how I can sort the Pictures in one Album by name? I just found the option for the Albums.

    Currently you can sort regular albums manually or by date; Smart Albums only by date; see How can you sort Album or Smart Album photos?

  • I scanned an old photo but the date displayed is today, I want the date to be the date the photo was taken.  How do I change the date of the photo in iPhoto 11?

    I scanned an old photo but the date displayed is today, I want the date to be the date the photo was taken.  How do I change the date of the photo in iPhoto 11?

    There are two kinds of metadata involved when you consider jpeg or other image file.
    One is the file data. This is what the Finder shows. This tells you nothing about the contents of the file, just the File itself.
    The problem with File metadata is that it can easily change as the file is moved from place to place or exported, e-mailed, uploaded etc.
    Photographs have also got both Exif and IPTC metadata. The date and time that your camera snapped the Photograph is recorded in the Exif metadata. Regardless if what the file date says, this is the actual time recorded by the camera.
    Photo applications like iPhoto, Aperture, Lightroom, Picasa, Photoshop etc get their date and time from the Exif metadata.
    When you export from iPhoto to the Finder new file is created containing your Photo (and its Exif). The File date is - quite accurately - reported as the date of Export.
    However, the Photo Date doesn't change.
    The problem is that the Finder doesn't work with Exif.
    So, your photo has the correct date, and so does the file, but they are different things. To sort on the Photo date you'll need to use a photo app.

  • How shall I delete the data from R/3 setup tables

    Hi Experts,
    How shall I delete the data from R/3 setup tables
    Regards
    Sailekha

    Hi Sailekha , to delete the set up table in r/3 either u can go to tcode LBWG as already mentioned or u can also delete the same from tcode SBIW
    Settings for Application-Specific DataSources (PI)  -
    Logistics -
    Managing Extract Structures -
    Initialization -
    Delete the Contents of the Setup Tables .
    Just click the clock there then u hace toi juct give the application component name like for Inventory 3 , then execute it , it will delete the set up table for inventory ..
    Regards..

  • How do u solve the data mismath ticket with example

    Hi
    This is Jgadeesh
    can any one tell  this
    how do u solve the data mismath ticket with example
    Thanks
    Jagadeesh

    Unfortunately, Apple removed the feature to "browse backups" in Time Machine backups of iPhoto a few years ago.
    You have to restore the entire iPhoto library to a separate location to be able to "see" it, and then choose the specific images that you want use.
    For complete details, see #15 in Pondini's excellent support document Time Machine -- FAQ.  Check the information in the pink box there.
    Frequently Asked Questions

  • How to delete the data in a table using function

    hi all,
    i need to delete the data in a table using four parameters in a function,
    the parameters are passed through shell script.
    How to write the function
    Thanks

    >
    But the only thing is that such function cannot be used in SQL.
    >
    Perhaps you weren't including the use of autonomous transactions?
    CREATE OR REPLACE FUNCTION remove_emp (employee_id NUMBER) RETURN NUMBER AS
    PRAGMA AUTONOMOUS_TRANSACTION;
    tot_emps NUMBER;
    BEGIN
    SELECT COUNT(*) INTO TOT_EMPS FROM EMP3;
    DELETE FROM emp3
    WHERE empno = employee_id;
    COMMIT;
    tot_emps := tot_emps - 1;
    RETURN TOT_EMPS;
    END;
    SQL> SELECT REMOVE_EMP(7499) FROM DUAL;
    REMOVE_EMP(7499)
                  12
    SQL> SELECT REMOVE_EMP(7521) FROM DUAL;
    REMOVE_EMP(7521)
                  11
    SQL> SELECT REMOVE_EMP(7566) FROM DUAL;
    REMOVE_EMP(7566)
                  10
    SQL>

Maybe you are looking for

  • How to use Airplay in Keynote with iPad 1

    The new update for Keynote for iOS (1.5) says that they now added AirPlay support. They didn't say this will only be for iPad2 or iPhone 4S where you could mirror anyway. So: How can I enable Airplay on my iPad1 in Keynote, so that the presentation w

  • How can I set up an inactive iPhone 3GS as an iPod?

    I have an inactive iPhone 3GS that has been restored to factory settings. I can not seem to get past the setup screens without putting in an active sim card. I don't have a sim card to put in it, nor do I want to put one in, I only want to use it for

  • Soft Proof in LR:   Put it in LR!

    I must have (like that, must have?) soft proofing abilities in LR if I am going to be able to use LR for preparing images for printing. Cheers

  • How can I get a new rear cover for iphone (not 3G)

    I have the older iphone 16GB (not 3G). it was broken when I dropped it. I tried taking it apart, and of course, I bent the aluminum back cover of the phone and can't get it back to the exact shape it was in before I bent it. Does anyone know where I

  • Link among Vendor, Expenditure Gl account and withholding tax keys

    Hi, could you pls clarify me regarding below Suppose i am having One Vendor (XYZ) and i am paying him more than one nature of payments (contract, rent, commission etc).  My end user wants the system to calculate the respective tax codes when ever iam