简体   繁体   中英

SQL Merging 2 rows based on multiple criteria

I would like to merge 2 rows in a query based on multiple criteria (in this ex: Date and Serial #). I've tried a couple of self joins but cant seem to get it to work. I currently have data like the top 2 rows and would like to get it to the lowest row.

Any help would be greatly appreciated

行合并

我认为您应该使用UNION或UNION ALL

Use aggregation:

select itemtype, serialnumber, min(trantype) as trantype, changed,
       min(orderform) as orderform, . . .
group by itemtype, serialnumber, changed;

I don't know what the logic is for trantype , so I'm just guessing.

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