How to produce latest column date comparing with the rest of 6 columns??

Hi Folks,
I have columns like below:  I need my LatestColumn(new col) need to produce maximum callbacktime 
the condition 
So something like MAX(Callback1datetime (where Callback1Status IS NOT NULL), Callback2datetime (where Callback2Status IS NOT NULL), CallbackStatus3datetime (where Callback3Status IS NOT NULL),etc…)
callback6Date Time has maximum time but callback6status has null then I need to skip this like above condition.
Thank you very much for your time 

hi Visakh 
Thank you very much for your replay to my question,
SELECT  t.Callback1DateTime,t.Callback1Status,t.Callback2DateTime,t.Callback2Status,t.Callback3DateTime,t.Callback3Status,t.Callback4DateTime,t.Callback4Status,t.Callback5DateTime,t.Callback5Status,t.Callback6DateTime,t.Callback6Status
,MAX(t1.dt) AS MaxCallBackDate
FROM dbo.Client t
CROSS APPLY ((Callback1DateTime,Callback1Status)
,(CallBack2datetime,Callback2Status)
,(CallBack3datetime,Callback3Status)
,(CallBack4datetime,Callback4Status)
,(CallBack5datetime,Callback5Status)
,(CallBack6datetime,Callback6Status))t1(dt,status1)
WHERE t1.STATUS1 IS NOT NULL
GROUP BY  t.Callback1DateTime,t.Callback1Status,t.Callback2DateTime,
t.Callback2Status,t.Callback3DateTime,t.Callback3Status,t.Callback4DateTime,t.Callback4Status,
t.Callback5DateTime,t.Callback5Status,t.Callback6DateTime,t.Callback6Status
I am getting error like this ::::::::::
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ','.
there was a typo
SELECT t.Callback1DateTime,t.Callback1Status,t.Callback2DateTime,t.Callback2Status,t.Callback3DateTime,t.Callback3Status,t.Callback4DateTime,t.Callback4Status,t.Callback5DateTime,t.Callback5Status,t.Callback6DateTime,t.Callback6Status
,MAX(t1.dt) AS MaxCallBackDate
FROM dbo.Client t
CROSS APPLY (VALUES (Callback1DateTime,Callback1Status)
,(CallBack2datetime,Callback2Status)
,(CallBack3datetime,Callback3Status)
,(CallBack4datetime,Callback4Status)
,(CallBack5datetime,Callback5Status)
,(CallBack6datetime,Callback6Status))t1(dt,status1)
WHERE t1.STATUS1 IS NOT NULL
GROUP BY t.Callback1DateTime,t.Callback1Status,t.Callback2DateTime,
t.Callback2Status,t.Callback3DateTime,t.Callback3Status,t.Callback4DateTime,t.Callback4Status,
t.Callback5DateTime,t.Callback5Status,t.Callback6DateTime,t.Callback6Status
Also i assume you're using version above 2008 as above syntax will work only from 2008 onwards
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • When I buy a pre order song how do I get it to play with the rest of the CD?

    When I buy a pre-order song from i tunes, and then purchase the CD the song was from it will not play with the rest of the CD.
    Example: Tori Amos's new CD Unrepentant Geraldines
    I purchased the single Trouble's Lament when it was released, before the CD.
    I just purchased the CD and the song should be #2 on the CD, but its not there, it is listed separately, and will not play with the CD.
    Also, other issue... Free U2 CD, it says its in my Library when I clicked on the CD add in the store. It's nowhere to be found in my library!! I really would love to listen to it since I have several of there CD's and am a big fan
    If anyone can help with either of these issues , I would greatly appreciate it.

    For the single, if you select the track in your library and do 'get-info' (control-I) on it and select its Summary tab on the popup are its details (e.g. album name and artist) the same as for the other tracks on the album ?
    For the U2 album you should be able to download it into your library by ticking the 'show iTunes in the Cloud purchases' tick box on the Store tab in iTunes > Preferences - it should then show in the Music part of your library with a cloud icon against it for downloading (downloading the booklet for it this way may not work, you may get a 'corrupt file' message when trying to open it, though that might have been fixed by now).
    Or go to the Purchased link under Quick Links on the right-hand side of the iTunes store homepage and you should be able to download it from there.
    A third option is to sign out of your account (Store > Sign Out menu option), find the album in the store and then click on its free 'price' button - you should then be prompted to sign back in and the album should download.

  • Ap Div - How to make them move in browser with the rest of the page?

    I have designed a site, but have placed an ap div "enrol now" button over an image, and when I view it in my browser, the ap div button does not move with the rest of the page.
    http://www.moreefamilydaycare.com/HOME_02test.html
    The "view our gallery" ap div is working.
    Please help.
    (you can see where the enrol now button should appear as I have put it in the main image pic aswell as a guide.)

    APDivs are very tricky to work with especially if use them inappropriately as a primary layout method.
    Here is why:
    http://apptools.com/examples/pagelayout101.php
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • Moving LR5 catalog (Irdata & Ircat) to a new hard drive and photos. Lost all meta data - How do I move meta data along with catalog?

    I moved LR5 catalog (Irdata & Ircat) to a new hard drive and photos. Lost all meta data - How do I move meta data along with catalog?
    The meta data for each image is missing.
    I have over 2,000 images. I don't want to go back through each image and add meta data.
    Is there some way to move everything?

    No, do not re-import your images. I assume you can see the thumbnails in the library module, just cannot access the full images, right? If this is the case there should be an exclamation mark in the top right corner of every one of your pictures and you only have to tell LR where the images are now.
    Click the exclamation mark of one of the images and a dialog window should pop-up, telling you that LR cannot find the file, but with an option to locate it. Press "Locate" and navigate to the folder on your new HD where the file is. If in the new external HD you kept the same folder structure that you had on the internal disk, LR will be able to find all your images and re-link them to the database without further intervention.

  • Oracle Forms - How can I create a Data Block with query

    Dear friends I have a question, I couldn't do this..
    I have a sql query, I want to show the datas of the query.. How can I do this. ?
    Data Block Wizard wants a table, view or stored procedure, but I have a query, how can I create a data block with my query.. I m waiting your helps..? Please...
    Semih

    Hi,
    You have two options
    1. create a view and base the block on the view
    2. create a block with a query Data Source Type of 'FROM clause query'
    Hope this helps
    Neil

  • How can i define a boolean variable with the condition if i got a specific text on a selected column?

    How can i define a boolean variable with the condition if i got a specific text on a selected column?
    Example:
    my select results:
    [id = 102] [Company = 'Microsoft']
    If i got microsoft in 'Company' i want to my another table with the columnName "Microsoft" get "true".
    Can you help me?

    That is called 2-table UPDATE.
    Example:
    http://www.sqlusa.com/bestpractices2005/updatewithcorrelatedsubquery/
    Kalman Toth Database & OLAP Architect
    Free T-SQL Scripts
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to keep data integrity with the two business service in OSB 10.3.1.0

    How to keep data integrity with the two business service in OSB 10.3.1.0
    In our customer system, customer want to keep data integerity between two businness service. I thinks this is XA transaction issue.
    Basing customer requirment, I created a testcase but I can't keep data integerity, For detail information, please refer the attached docs.

    Can you please explain what you meant my data integrity in your use case?
    Manoj

  • Why does iMessages does not work properly ? Please help me ! Its works better with the previous version if compared with the latest iOS

    Why does iMessages does not work properly ? Please help me ! Its works better with the previous version if compared with the latest iOS

    Many, many thanks for both of you Todd and Rick.
    to Rick:
    I suppose you mean the Color Settings in Project Settings as follows:
    - Working Space: None
    - Match Legacy ... Gamma Adjustments checked ON
    But it does not correct the colors in effects. And checking or unchecking Make Movie/Output Module Settings/Color Management/Profile/Preserve RGB does not make any difference.
    to both of you:
    Those parts of the video image that does not have color effects are just fine. In these parts the color is preserved when reimporting to FCP. However, those parts having color effects (except Levels, as decribed earlier) have altered color results. So, only the parts having effects affecting color are misinterpreted in the image area. The mismatch is of course seen in AE, before making the movie.
    What I ment with "Color Management not working properly" is that (instead of "disabling" it) Color Management does not seem to be able to correct this "misinterpretation" or difference in effect handling between AE 6 and 10.
    So, would you have any solution for this problem?
    Again, many thanks for your fast replies!

  • How can I make the message date appear with the time for unread messages?

    Mail systems I am moving from display the date & time with the messages. I need this displayed to determine aging and importance of received mail. When archiving/saving old mail it helps filing mail off and not duplicate archived messages.

    Thunderbird displays time and date for all messages except for the present day messages. The time only is displayed for today and the date is appended at midnight.

  • Benefits of SAP Business Warehouse Reporting compared with the Query-tools?

    Hello experts,
    I've been creating reports with SAP Query tools, but been faced with few problems. First of all, there are restricted possibilities in terms of joining tables, and thus I cannot include all the data required for the report.
    One solution for this would have been to create separate queries and join the data together in Excel. The problem with this is that there exists no common field that would make sense as for a selection criterion. If the selection criterion is different in different queries, there is the danger of combining false data together, which would eventually result with distorted data. 
    So I was wondering, could anyone briefly tell me if SAP Business Warehouse reporting would solve these problems? And what other benefits would it provide compared with the SAP Query? I'd urgently need to know if it would be a beneficial investment for the company, since I haven't found solutions for the problems occurred in the creation of reports.
    Thank you in advance for you help!
    Maria

    The answers are yes - and thousands of companies have gone down this route
    Puttingin BW is a strategic aim of the comapny and not to be thought about and discussed in a BI forum such as this
    The costs of implementation and hardware will no doubt make your eyes water.
    To be quite honest SAP BI is a "no brainer" as most of the new e-SOA and new R3 modules reply on BW for their reporting needs

  • How do I fill an Excel spreadsheet with the contents of a DataTable? (C#, OleDb)

    The following fills a DataTable with the contents of an Excel spreadsheet.
        oledbCmd.CommandText = "SELECT * FROM [" + stSheetName + "$]";
        DataTable dtDataTable = new DataTable();
        using (OleDbDataAdapter oledbAdapter = new OleDbDataAdapter(oledbCmd))
        oledbAdapter.Fill(dtDataTable);
    How do I fill an Excel spreadsheet with the contents of a DataTable?
    bhs67

    You can try this Excel library, it can help u to
    export datatable to excel to Database.
    After add the reference to your project ,add the following code:
    private void button1_Click(object sender, EventArgs e)
    //connect database
    OleDbConnection connection = new OleDbConnection();
    connection.ConnectionString @"Provider=""Microsoft.Jet.OLEDB.4.0"";Data Source=""demo.mdb"";User Id=;Password="
    OleDbCommand command = new OleDbCommand();
    command.CommandText = "select * from parts";
    DataSet dataSet = new System.Data.DataSet();
    OleDbDataAdapter dataAdapter = new OleDbDataAdapter(command.CommandText,connection);
    dataAdapter.Fill(dataSet);
    DataTable t = dataSet.Tables[0];
    //export datatable to excel
    Workbook book = new Workbook();
    Worksheet sheet = book.Worksheets[0];
    sheet.InsertDataTable(t, true, 1, 1);
    book.SaveToFile("insertTableToExcel.xls");
    System.Diagnostics.Process.Start("insertTableToExcel.xls");
    http://www.e-iceblue.com/Tutorials/Spire.XLS/Spire.XLS-Program-Guide/Data-Export-/Import-Export-Datatable-to-Excel-from-Database.html

  • How to get latest record on top of the result list

    Hi Gurus,
    How to get latest record on top of the result list when you open the record.
    saved data method in BT120H_CPL of OverView page and result list in ICCMP_INBOX.
    Regards,
    Ravi

    Hi
    Try sort descending by on fileld "changed at ".
    manipulate the sort depends on your requirement
    Regards
    Logu

  • I have an external hard drive that was formatted by a PC and has files and directories etc. I want to format it and use it on my IMAC for backup but I can't seem to write to it nor can I delete current content. How do I initialize it for use with the MAC?

    I have an external hard drive that was formatted by a PC and has files and directories copied to it etc. I want to use it on my IMAC for backup. I see it on my my IMAC . I can open files etc.  But I can't seem to write to it nor can I delete current content. I don't care if I lose current content. How do I initialize it for use with the MAC?

    You can't write to it because it's formatted as NTFS which OS X will read but not write to. If you want to continue using the drive with both a PC and OS X you will need to download and install NTFS-3G so you can then write to it from your Mac. You can get NTFS-3G at:
    http://www.macupdate.com/app/mac/24481/ntfs-3g
    If you want to use the drive exclusively with your Mac then move the data off it and reformat it in Disk Utility (Applications - Utilities - Disk Utilities) as Mac OS Extended (Journaled.)

  • My iPhone has my old email set up throught iCloud. How do I reset my new username with the device without deleting everything. And if I have to delete my old account, will everything (contacts, pictures, games, apps, etc.) be erased from my phone.

    My iPhone has my old email set up throught iCloud. How do I reset my new username with the device without deleting everything. And if I have to delete my old account, will everything (contacts, pictures, games, apps, etc.) be erased from my phone.

    Your old ID connects to an icloud account containing all your data (email, contacts, etc.)  If you then use a different ID, you will connect to a different account, which results in losing all your "apple" data, like emails, contacts, calendars, etc.
    However, Apple IDs are also used to connect to an itunes store account, with is different.  You can keep using the old itunes store ID to keep all your purchases (but if you change to a different ID, you will lose all purchased items) and use the new ID for icloud (but losing emails, contacts, etc. from the old account).

  • PS CC 2014 DNG and RAW 8.5 did not update with the rest of the CC package. I downloaded/installed the DNG/RAW converter but how do you install w/i CC 2014 plugins

    PS CC 2014 DNG and RAW 8.5 did not update with the rest of the CC package. I downloaded/installed the DNG/RAW converter but how do you install w/i CC 2014 plugins

    Thanks John. I have tried solutions 1 to 3 from (-http://helpx.adobe.com/creative-cloud/kb/aam-lists-removed-apps-date.h tml) and they do not work. So I presume that all I can do is to remove all 25 CC applications and start again!
    Incidently, ( http://www.adobe.com/downloads/updates/ ) does not list Adobe Camera Raw 8.4 as an update even though Adobe have announced that it is available (http://blogs.adobe.com/lightroomjournal/2014/04/camera-raw-8-4-and-dng-converter-8-4-now-a vailable.html). The same applies for Adobe Premiere Pro 7.2.2 (http://blogs.adobe.com/premierepro/2014/04/premiere-pro-cc-7-2-2.html). If they are not available this would explain why I cannot download them but I am very suprised that Adobe didn't mention this when I contacted them.
    Anyway thanks again

Maybe you are looking for

  • Shell program and XML Publisher E-Text Template

    Hi All, We have a customer submitting an rdf report through Shell script using the command line submission ar60run. This is being done in 11i. This rdf handles the File transmission with certain codes for the third party(same as E-Text templates in R

  • Settings and volume issues

    My settings have been changing randomly.  Also my volume and volume controls have been working sporadically since the update...  i have restored my phone 2x.   now what??

  • Importing layered pdfs into Photoshop

    I'm a landscape architect and use Photoshop to colour up my CAD designs. It is a big time saver if I could carry across the separate layer information in my CAD plan to within Photoshop - it would make it much quicker to colour in just the paths, for

  • Send CC emails not successful

    Dear All, I am using the javax.mail to send email my only problem is sending multiple CC copies. Below is a part of my codes. This line where I set the CC does not work emailMessage.setRecipients(Message.RecipientType.CC,InternetAddress.parse(eMArray

  • Installing gmail on an ipad air

    I am attempting to install gmail ( recently established account) on the ipad air with ios 7.0.4.  I include the IMAP setting and the SMTP settings with sync.  The error message comes back that it was not successful installing the gmail account and th