Can you select the max of a group by and mach it to another table?

I can't get my little head around this one. I have 2 tables
table 1:
T1ID col1 col2 col3
1 a t e
2 g y a
3 h r p
4 f u w
and table 2 that has many entries from table 1
Table 2:
T1ID ID col1
1 3 Y
1 2 M
1 1 H
3 2 W
3 1 E
I want the contents of table 1 with the value of col1 from table 2 where the ID is the highest?
so returning table 3:
ID col1 col2 col3 col1_from_table_3
1 a t e Y
2 g y a
3 h r p W
4 f u w
is this easy to do with a select statment?
Thanks for all of you help(in advance)
LT

SQL> create table t1 (t1id,col1,col2,col3)
  2  as
  3  select 1, 'a', 't', 'e' from dual union all
  4  select 2, 'g', 'y', 'a' from dual union all
  5  select 3, 'h', 'r', 'p' from dual union all
  6  select 4, 'f', 'u', 'w' from dual
  7  /
Tabel is aangemaakt.
SQL> create table t2 (t1id,id,col1)
  2  as
  3  select 1, 3, 'Y' from dual union all
  4  select 1, 2, 'M' from dual union all
  5  select 1, 1, 'H' from dual union all
  6  select 3, 2, 'W' from dual union all
  7  select 3, 1, 'E' from dual
  8  /
Tabel is aangemaakt.
SQL> select t1.t1id id
  2       , max(t1.col1) keep (dense_rank last order by t2.id) col1
  3       , max(t1.col2) keep (dense_rank last order by t2.id) col2
  4       , max(t1.col3) keep (dense_rank last order by t2.id) col3
  5       , max(t2.col1) keep (dense_rank last order by t2.id) col1_from_t2
  6    from t1
  7       , t2
  8   where t1.t1id = t2.t1id (+)
  9   group by t1.t1id
10  /
   ID COL1  COL2  COL3  COL1_FROM_T2
    1 a     t     e     Y
    2 g     y     a
    3 h     r     p     W
    4 f     u     w
4 rijen zijn geselecteerd.Regards,
Rob.

Similar Messages

  • Can you connect the Lightning to 30-pin adapter and Lightning to 30-pin Adapter (0.2 m) to iPod nano (7th generation) with third-party accessories?

    Can you connect the Lightning to 30-pin adapter and Lightning to 30-pin Adapter (0.2 m) to iPod nano (7th generation) with third-party accessories?

    Lightning to 30-pin adapter and Lightning to 30-pin adapter (0.2m) do not work if connected together by other third-party accessories.

  • Can you take the SIM card from an IPad and transfer it to a NEW Ipad (not yet purchased) without any problems? Are there any complicated steps involved? Thanks.

    Can you take the SIM card from an IPad and transfer it to a NEW Ipad (not yet purchased) without any problems? Are there any complicated steps involved? This is for my boss.
    Please let me know. Thanks in advance.

    Simple answer is YES.
    The only caviat is for instance in the UK some iPads are locked to a specific network provider and therefore if the new iPad is locked then it will only work on the specific network it is locked to.

  • Can you cancel Adobe Photoshop CS6 from one computer and put it on another?

    Can you cancel Adobe Photoshop CS6 from one computer and put it on another computer?

    Yes. You have to deactivate it on one computer and then you can install it and activate it on another. Technically, your license allows you to have Photoshop CS6 installed and activated on two computers, you just can't use both at the same time.

  • How can you set the max row for a 'open cursor' in a stored proc?

    I would like to know how can you set the maximum amount of row returned in a resultset coming from a stored proc?
    You can do it via JDBC with cStatement.setMaxRows(10); but it works only for select that you do via JDBC...
    I would like the same functionality using open cursor inside a stored proc...
    Thanks...

    is "where ROWNUM <= 10" the equivalent of "cStatement.setMaxRows(10);" because the ROWNUM as problem with the ORDER BY clause and the setMaxRows() as no problem...

  • In ical, how can you tell the difference between a meeting invite and email?

    When you send a meeting invite in ical, does the recipient receive a different icon in their inbox to differentiate from an email?

    For service stock you can't tell the difference between a new iPad and a refurbished one. Both will come in a plain brown box with the same pattern in model numbers. If you mean between a refurbished one and one new at retail, then other than the obvious difference in packaging, I've read that the model number on refurbished units starts with the letter "F", though I've not confirmed that.
    Regards.

  • How can you tell the differance between an iphone charger and an ipad charger?

    how can you tell the differance between an iphone and ipad charger

    http://store.apple.com/us/product/MC359LL/A/apple-ipad-10w-usb-power-adapter?fno de=3c
    http://store.apple.com/us/product/MD810LL/A/apple-5w-usb-power-adapter?fnode=48

  • How can you select the "from" in Mail with multiple accounts?

    Is there a simple dropdown to select the "From" field in Mail when using multiple accounts?
    All I can find is a support page saying From is defined by the email account that is highlighted and active.
    Thanks

    Hoo,
    When you hover your mouse over your name in the from field it presents a little arrow. Click it and it lets you select who you are sending an email as.
    Also if your reading an email that you got say to your @iCloud.com email when you hit compose it will automatically select your @iCloud.com email to compose your email.
    Hope that helps,
    Weston

  • Can you select the server name or I.P. from SQL

    I am trying to find where I can get the server name or IP address from an SQL query, Can you Help?

    Do you mean the database host? It's like this:
    SQL> select host_name from v$instance;
    HOST_NAME
    sqlintdb4                                                                                                                                                                                                                                                                                                                               

  • HT3819 can you select the items you don't want your family to be able to see?

    I want to get some of my dad's songs he has on his ipod without buying them so i was going to try using the home sharing but i dont want to share all of my songs. Before i turn home sharing on i would like to know if i can select the items i want and don't want my family to be able to see

    I really do appreciate everyone's input to my question. I guess what I wanted to do, and how it can be done aren't as simple as I had hoped. But I know what will work now. Thank you again and have a nice holiday season.

  • Can you select the row in a table view without highlighting the cell?

    I have an an app with a table view which is presented modally. Cell selections in this table are saved in the parent controller so that they can be reselected if the table is reloaded after being dismissed.
    When the cell is first highlighted, I want to momentarily highlight the cell and have it fade out, which I do by unselecting the cell from the modal view controller's didSelectRowAtIndexPath by calling setSelected:animated on the table view cell.
    However, when I present the table view controller modally again and want to display the previously selected cell as selected, I don't want the cell background to be highlighted, and I'm having trouble doing this.
    In order to make sure the table view knows the cell is selected, I am calling selectRowAtIndexPath. I need to make sure the cell is selected so that I can set/unset the cell's accessoryType. However, this has the sideeffect of highlighting the cell too, which looks weird and confusing to the user.
    I've tried things like temporarily setting the cell's selection style to none, but while that stops the cell background from highlighting? I've tried setting the selectionStyle to UITableViewSelectionStyleNone, but while this prevents the cell background from highlighting, the cell text still changes to white, so it the text is invisible against the white background.
    Is there a easy way of setting a cell to selected in the table view without also changing the highlight and text colour of the actual cell? Immediately setting the cell to be unselected still makes the highlight visible for a split second.

    I tried that, but setting the highlighted property doesn't seem to affect it.
    I figured out how what I was doing wrong though. I was setting selection style UITableViewSelectionStyleNone, selecting the cell, then setting the selection style back to whatever it had previously been. This causes the background not to draw highlighted, but the text and accessory type to still draw highlighted.
    In order to fix this, I moved the code to set the cell selection style to whatever it had previously been to the didDeselectRowAtIndexPath method.

  • How can you use the same Apple ID for music and apps but have a different iCloud

    Collectively in my family we have 1 iPhone 2 ipod(4th gen) and 3 iPad mini's and we like to buy music and apps through the same Apple ID so that we can all share it but we also have a problem about the iCloud.
    My son has one iPod and one iPad and he would like his contacts and messages to be shared between HIS two devices but he would also like all of the pictures taken in the family to be shared
    The same for my daughter and for me.
    Is there a way of selecting which devices share what????
    Thanks a lot
    Acwills

    You could and should set up different iCloud accounts in "Settings > iCloud", so that every user has its own email account, calendars, reminders, notes, storage for backups and app data (files etc.), by the way everyone could also use his own account for iMessage (Settings > Messages > Send & Receive) and FaceTime (Settings > FaceTime) so that you all could write and call each other.
    Next the Apple ID for music, apps and other media: You all could just set up the ssame Apple ID in "Settings > iTunes & App Stores" for all your media purchases like songs, movies, apps etc.

  • I deleted my download folder and now I can't download anything. I can't select the folder to "save file to" and when I select "ask me where to save files" I still can't download. it says your file will start downloading, but then it doesn't. Help!!

    I deleted the folder that saves everything that is downloaded from Firefox. After that I can't download anymore. I've tried clearing my download history, reset the download folder, reset the download action by renaming the mimetype.rdfs file and it's still not working. I've tried to choose a different download folder but it doesn't let me select any folder at all. If I select "ask me where to save files" and then try and download something, the download doesn't start after I select save to. The only time it does actually download is when I select "open with...windows mediaplayer" when downloading then the download will start. Please help. Thank you.

    You broke your phone by getting it wet.  Nothing more to say.  Bring it in to Apple for an out of warranty exchange or buy a new phone.  There's really nothing else we users here can help you with.

  • Can you improve the speed of my CSV Reader and Writer?

    hi all, i'm trying to develop a CSV Writer and Reader. i have done a good work to implement the special character and quoting it, it's also support multi line value but it's incredibly slow.
    can someone help to make it faster?
    here it's how to use the writer
    char *stringhe_sorgenti[10] = {0};
    out = OpenFile(nfile, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII);
    for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
    stringhe_sorgenti[i] = (char*)calloc(200, sizeof(char));
    sprintf(stringhe_sorgenti[0], "example1");
    sprintf(stringhe_sorgenti[1], "example2");
    scrivi_riga_csv(out, stringhe_sorgenti, sizeof(stringhe_sorgenti)/sizeof(char*), formato);
    for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
    free(stringhe_sorgenti[i]);
    CloseFile(out);
    here is the writer 
    void scrivi_riga_csv(int file_handle, char *stringa_sorgente[], int numero_stringhe, int formato)
    char delimitatore[2][2] = {{',', '\0'}, {';', '\0'}};
    char stringa_destinazione[1024] = {0};
    int index_destinazione = {0};
    int index_start = {0};
    int index_fine = {0};
    int errore = {0};
    int i = {0};
    //int k = {0};
    size_t lunghezza_stringa = {0};
    for(i = 0; i < numero_stringhe; i++){
    if(i != 0){
    stringa_destinazione[index_destinazione++] = delimitatore[formato][0];
    index_start = 0;
    lunghezza_stringa = strlen(stringa_sorgente[i]);
    // se la stringa sorgente
    if( (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, delimitatore[formato], 0, 0) != -1) // contiene delimitatore
    || (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, "\"", 0, 0) != -1) // contiene parentesi
    || (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, "\n", 0, 0) != -1) // contiene a capo
    // apro parentesi all'inizio
    stringa_destinazione[index_destinazione++] = '"';
    // metodo find pattern, piu' complesso ma piu' performante
    do{ index_fine = FindPattern(stringa_sorgente[i], index_start, lunghezza_stringa - index_start, "\"", 0, 0);
    if(index_fine != -1){
    index_fine++;
    // copio dall'inizio fino alle virgolette
    CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], index_start, index_fine - index_start);
    index_destinazione += index_fine - index_start;
    // ne aggiungo una dopo
    stringa_destinazione[index_destinazione++] = '"';
    // aggiorno la posizione di start e riparto con il while
    index_start = index_fine;
    }while(index_fine != -1);
    CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], index_start, lunghezza_stringa - index_start);
    index_destinazione += strlen(stringa_sorgente[i]) - index_start;
    // alla fine della riga chiudo la parentesi
    stringa_destinazione[index_destinazione++] = '"';
    else{
    // altrimenti la copio semplicemente e shifto l'indice della stringa di destinazione
    CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], 0, lunghezza_stringa);
    index_destinazione += strlen(stringa_sorgente[i]);
    memset(stringa_sorgente[i], 0, strlen(stringa_sorgente[i]));
    errore = WriteLine (file_handle, stringa_destinazione, strlen(stringa_destinazione));
    if(errore == -1){
    errore = GetFmtIOError();
    MessagePopup("WriteLine -> WriteLine", GetFmtIOErrorString(errore));
    return;
     here how to read the file
    char *stringhe_sorgenti[10] = {0};
    for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
    stringhe_sorgenti[i] = (char*)calloc(200, sizeof(char));
    out = OpenFile(nomearchivio, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_BINARY);
    leggi_riga_csv(out, stringhe_sorgenti, sizeof(stringhe_sorgenti)/sizeof(char*), formato);
    strcpy(intestazione.data, stringhe_sorgenti[1]);
    for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
    free(stringhe_sorgenti[i]);
    CloseFile(out);
     and here the reader
    void leggi_riga_csv(int file_handle, char *stringa_destinazione[], int numero_stringhe, int formato)
    char delimitatore[2][2] = {{',', '\0'},
    {';', '\0'}};
    char stringa_sorgente[1024] = {0};
    int stringa_in_corso = {0};
    int index_inizio_valore = {0};
    int index_doublequote = {0};
    int offset_stringa_destinazione = {0};
    size_t lunghezza_stringa = {0};
    int inquote = {0};
    int errore = {0};
    int i = {0};
    for(i = 0; i < numero_stringhe; i++){
    lunghezza_stringa = strlen(stringa_destinazione[i]);
    memset(stringa_destinazione[i], 0, lunghezza_stringa);
    do{ memset(&stringa_sorgente, 0, sizeof(stringa_sorgente));
    errore = ReadLine(file_handle, stringa_sorgente, sizeof(stringa_sorgente) - 1);
    // If ReadLine reads no bytes because it has already reached the end of the file, it returns –2.
    // If an I/O error occurs, possibly because of a bad file handle, ReadLine returns –1.
    // You can use GetFmtIOError to get more information about the type of error that occurred.
    // A value of 0 indicates that ReadLine read an empty line.
    if(errore == -1){
    errore = GetFmtIOError();
    MessagePopup("leggi_riga_csv -> ReadLine", GetFmtIOErrorString(errore));
    return;
    else if(errore == -2){
    errore = GetFmtIOError();
    MessagePopup("leggi_riga_csv -> ReadLine", "already reached the end of the file");
    return;
    else{
    lunghezza_stringa = errore;
    index_inizio_valore = 0;
    // metodo find pattern, piu' complesso ma piu' performante
    for(i = 0; i <= lunghezza_stringa; i++){
    // se come primo carattere ho una " allora e' una stringa speciale
    if(inquote == 0){
    if(stringa_sorgente[i] == '\"'){
    inquote = 1;
    index_inizio_valore = ++i;
    else{
    // altrimenti cerco il delimitatore senza il ciclo for
    i = FindPattern(stringa_sorgente, i, lunghezza_stringa - index_inizio_valore, delimitatore[formato], 0, 0);
    if(i == -1){
    // se non lo trovo ho finito la riga
    i = lunghezza_stringa;
    if(stringa_sorgente[i - 1] == '\r'){
    i--;
    if(stringa_in_corso < numero_stringhe){
    CopyString (stringa_destinazione[stringa_in_corso], 0, stringa_sorgente, index_inizio_valore, i - index_inizio_valore);
    offset_stringa_destinazione = 0;
    stringa_in_corso++;
    if(stringa_sorgente[i] == '\r'){
    i++;
    index_inizio_valore = i + 1;
    if(inquote == 1){
    // se sono nelle parentesi cerco le virgolette
    i = 1 + FindPattern(stringa_sorgente, i, lunghezza_stringa - index_inizio_valore, "\"", 0, 0);
    if(i == 0){
    if(stringa_sorgente[lunghezza_stringa - 1] == '\r'){
    lunghezza_stringa--;
    // se non le trovo ho finito la riga, esco dal ciclo for
    break;
    // se incontro una doppia parentesi salto avanti
    else if(stringa_sorgente[i] == '\"'){
    continue;
    // !!!! fondamentale non cambiare l'ordine di questi else if !!!!!
    // se incontro una parentesi seguita dal delimitatore
    // o se incontro una parentesi seguita dal terminatore
    // \r = CR = 0x0D = 13
    // \n = LF = 0x0A = 10
    // a capo = CR + LF
    else if( (stringa_sorgente[i] == delimitatore[formato][0])
    || (stringa_sorgente[i] == '\r')
    || (stringa_sorgente[i] == '\0')
    // salvo il valore
    inquote = 0;
    if(stringa_in_corso < numero_stringhe){
    CopyString (stringa_destinazione[stringa_in_corso], offset_stringa_destinazione, stringa_sorgente, index_inizio_valore, i - 1 - index_inizio_valore);
    offset_stringa_destinazione = 0;
    stringa_in_corso++;
    if(stringa_sorgente[i] == '\r'){
    i++;
    index_inizio_valore = i;
    // se sono andato a capo scrivo fino a dove sono e poi procedo con la nuova riga
    if(inquote){
    if(stringa_in_corso < numero_stringhe){
    CopyString (stringa_destinazione[stringa_in_corso], offset_stringa_destinazione, stringa_sorgente, index_inizio_valore, lunghezza_stringa - index_inizio_valore);
    strcat(stringa_destinazione[stringa_in_corso], "\n");
    offset_stringa_destinazione += lunghezza_stringa - index_inizio_valore;
    offset_stringa_destinazione++;
    }while(inquote == 1);
    // elimino le doppie parentesi
    for(i = 0; i < numero_stringhe; i++){
    index_doublequote = 0;
    do{ lunghezza_stringa = strlen(stringa_destinazione[i]);
    index_doublequote = FindPattern(stringa_destinazione[i], index_doublequote, lunghezza_stringa - index_doublequote, "\"\"", 0, 0); // contiene doppia parentesi
    if(index_doublequote != -1){
    index_doublequote++;
    memmove (stringa_destinazione[i] + index_doublequote, stringa_destinazione[i] + index_doublequote + 1, lunghezza_stringa - index_doublequote);
    }while(index_doublequote != -1);
    return;

    the format is CSV, i try to explain better what i'm doing.
    our client asked to save acquisition data with header description in an excel readable format, i've decided to use .CSV and not .TDM because it's a simple txt file and we never used .TMD but i will propose to use it.
    after some research on the internet i've found nothing to handle .CSV in CVI except from this csv_parse but i've found it difficult to be maintained so i've write it by my own hand.
    i've written two example of how to use my function to read or write and i've copyed my function used to read and write.
    in the write function i check with FindPattern if the string to be write contain some special character, if i find this i have to quote the string to respect the standard RFC4180 and if i find a quote i have to double it. aftere i've done this check i write the line in the file.
    in the read function, that is more complicated, i:
    check if the first character is a quote.
    if it's not i copy the string until the delimitier or until the end of the line.
    if it is i have a string with special character inside so:
    i find the first quote in the string. when i've found i check if it's follwed by another quote. this means that in the starting message i was writing a single quote.
    if it's not followed by another quote but it's followed by a delimiter or a carriage return i've finished the special line.
    if i don't find it it means that the special quote have a carriage return inside and i have to check the next line. before checking the next line i save this in my string.
    after this loop i check in every string if i have a double quote and i delete one.
    the main problem is in the speed of this, i'm acquiring data at 1000 S/s with 8 active channel for 60 second so i have 480000 data to be stored, divided in 60.000 row and 8 column. to read a file like that my pc stay "locked" for 15 second or more.
    i've tried to use the arraytofile function and it's extremly fast and i can also put header because the function can start from the last position in the file but the filetoarray function start from the beginning and i cannot read the header correctly. also if i'm using the european CSV with semicolon as delimiter with arraytofile i cannot select the semicolon but only the coma

  • Can you specify the allowable values for vertical range and offset for the NI 5112 PCI Digitizer?

    The NI 5112 manual indicates that the vertical range can be set from +/- 25mV to +/-25V in 10% steps. Can you explain exactly what this means? (For example, could you give me a series of allowable values.)
    Also, what are the allowable values for voltage offset?
    The reason for my question is: I am specifying the vertical configuration using the niScope_ConfigureVertical() function. The observed raw (8 bit) sampling does not appear to change at all for small changes in voltage range and offset. I would like to know where the hardware breakpoints are, so that I can apply correct scaling from bits to voltage.
    In addition, I have tried to use the niScope_CheckAt
    tributeViReal64() function to "check" a value before applying it to NISCOPE_ATTR_VERTICAL_RANGE or NISCOPE_ATTR_VERTICAL_OFFSET, but it fails in the linking step in Microsoft Dev. Studio. (niScope.lib & niscope_32.lib do not seem to contain any of the CheckAttribute functions that are listed in the NI-Scope function reference.)
    Thank you for your response.

    There is a nice reference at:
    http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/38f18d418e2433ed8625690e006bbe94?OpenDocument
    which explains that allowable voltage ranges can be expressed by the equation:
    next_range_value = range_value * 1.1 starting at +/- 25 mV.
    When a range is specified that does not match this series, the device driver rounds UP to the next value.

Maybe you are looking for

  • Standard report Variant creation

    Hi , i am trying to create the dynamic variant for standard report   RKWTP_CPTD, which contains the period and fiscal year fields on selection screen, now i need to create variant as period has to  be current month -1 month i.e it has to show previou

  • Javelin JSP compilation error

    Hello Everyone, I've a some JSP's that work some times and fail sometime with <head> <title>Javelin JSP compilation error</title> </head> <body> <b>Compilation of JSP File '/jsp/temp/Index.jsp' <font color=#FF0000>failed</font>:</b><HR> <pre> I tried

  • How to display thumbnail of files????

    i want to display my avi file list in thumbnail view as windows explorer is providing... can anyone tell me... how can i implement the same??

  • Flex automation support for Firefox 3.6.8

    Hi There, I have been using flex automation plugin for a while which comes with Flex Builder 3.0. Where it is mentioned that flex only supports automation with IE browser. Is the same comment applicable with Flas Builder 4 automation plugin. or is it

  • Does any one know if you use the plug-ins yhat you have in the new fcpx?

    does any one know if you use the plug-ins yhat you have in the new fcpx?