0

I have set of results from query that looks like this:

ID    Type  
6011    I
6411    I
6811    I
6911    I
6311    I
1021    L
1321    L
1421    L
1821    L
1921    L
2031    M
2431    M
2831    M
2931    M
2331    M
3041    S
3341    S
3441    S
3841    S
3941    S

Result set above is produced by this query:

SELECT rec_id, rec_type
FROM Table 1

I would like to show records like this:

             ID                  Type
6011, 6411, 6811, 6911, 6311      I
1021, 1321, 1421, 1821, 1921      L
2031, 2431, 2831, 2931, 2331      M
3041, 3341, 3441, 3841, 3941      S

I do not know how to achieve this in Sybase. Is this a good fit for PIVOT or UNPIVOT? If anyone knows the way to get this to look like result set above please let me know. Thank you.

espresso_coffee
  • 5,980
  • 11
  • 83
  • 193
  • which Sybase RDBMS product (ASE? SQLAnywhere? IQ? Advantage?) and version? – markp-fuso Mar 18 '19 at 16:46
  • @markp ASE 16.0 I think. – espresso_coffee Mar 18 '19 at 16:51
  • see my response to a similar question: https://stackoverflow.com/a/45092295/7366100 – markp-fuso Mar 18 '19 at 17:21
  • @markp The solution provided for ASE 16 doesn't give me any advantage of doing it that way better than with server side language. I'm surprised that there is not another approach/solution. I also was wondering if would be better to create SP then insert records in temporary table. – espresso_coffee Mar 18 '19 at 17:24
  • whether you're talking 'server side language' (?), stored proc or user defined function (UDF) ... you're still using a cursor-based method; which one (if any) works best for you is up to you to decide based on your specific requirements, maintenance overhead, and performance – markp-fuso Mar 18 '19 at 17:45

0 Answers0