简体   繁体   中英

Sql Query with all name records for an account listed on 1 record in output

I have a table of names and accounts. Each name is a separate record. An Account may have multiple names (each a separate record), but each name has a unique Ordinal in that Account. The Ordinals for each account may not be in succession. I want a listing of each Account (listed once) with all the names for that Account. See example. Thanks!

Table example:

|ACCOUNT  |NAMETYPE   |ORDINAL |FULLNAME  |
|:--------|:----------|:-------|:---------|
|123      |Joint      |0       |Joe Blow  |
|123      |Joint      |1       |Flo Blow  |
|123      |AuthSigner |2       |Don Duck  |
|456      |AuthSigner |0       |Min Mouse |
|456      |AuthSigner |4       |Mick Mouse|
|789      |Joint      |0       |C Little  |
|789      |Trustee    |1       |Bea Little|
|789      |Trustee    |3       |Bo Little |

Output example:

|ACCOUNT  |NAMETYPE   |FULLNAME    |NAMETYPE   |FULLTYPE    |NAMETYPE   |FULLNAME   |
|:--------|:----------|:----------|:-----------|:-----------|:----------|:-------|
|123      |Joint      |Joe Blow   |Joint       |Flo Blow    |AuthSigner |Don Duck   |
|456      |AuthSigner |Min Mouse  |AuthSigner  |Mick Mouse  |           |          |
|789      |Joint      |C Little   |Trustee     |Bea Little  |Trustee    |Bo Little   |

Example: 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM