SQL Script to pull duplicate data

ぐ巨炮叔叔 提交于 2019-12-11 21:06:50

问题


Need help pointing in right direction using an SQL query to extract data out of this SYBASE database example:

12345  blue
12345  red
12345  green
56789  purple
56789  black
98765  brown

output must look like this:
12345 blue red green
56789 purple black
98765 brown

Was trying to use "union" or maybe "distinct" Please point me in the right direction.


回答1:


Oracle uses WM_CONCAT or LIST_AGG to do this anymore I think sysbase uses List()

Source documentation describing function

So.. using your SQL

Select Field1, list(Field2)
FROM table
Group by Field1


SELECT item_loc.niin, list(item_loc.location_number)
FROM item_loc 
GROUP BY item_loc.niin

I just removed a space after list before the ( so List ( became List(

Now the nature of the error your getting indicates list isn't a function in your version of sybase... I'm still trying to find documentation on sybase 15.3 and proper syntax for it (or if it supports List)



来源:https://stackoverflow.com/questions/17094656/sql-script-to-pull-duplicate-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!