sivachirravuri
asked on
Maximum limit (46) of work tables is exceeded. Simplify the query and retry.
Hi Folks,
Please find me a way to solve the following issue.
I am trying to transpose data of a table. and because I have 90 columns after transpose I get following error.
Maximum limit (46) of work tables is exceeded. Simplify the query and retry.
I understand, on a ASE 15.0.2 the runtime limits is 46 tables.
example:
tblQuest
------------
DataID FA Code UserID
------- ------------- ------ -------
1760 use1.1 0 101
1761 use1.2 1 101
1762 use1.3 0 101
1763 useOS this is test 101
1764 use2.1 0 101
............ ...... ..... ....
............ ...... ..... ....
............ ...... ..... ....
1850 use4.4 0 101
1851 use1.1 1 102
1852 use1.2 1 102
1852 use1.3 1 102
1853 useOS enter fun 102
1854 use2.1 0 102
............ ...... ..... ....
............ ...... ..... ....
............ ...... ..... ....
I wrote a query to transpose this based on user. There will be 90-100 coulmns per user..
Like following
---------------
User use1.1 use1.2 use1.3 .............. use4.4
------ -------- ------- -------- --------
101 0 1 0 ......... 0
102 0 1 1 ........ 1
...... etc
Here is the query I use
Please find me a way to solve the following issue.
I am trying to transpose data of a table. and because I have 90 columns after transpose I get following error.
Maximum limit (46) of work tables is exceeded. Simplify the query and retry.
I understand, on a ASE 15.0.2 the runtime limits is 46 tables.
example:
tblQuest
------------
DataID FA Code UserID
------- ------------- ------ -------
1760 use1.1 0 101
1761 use1.2 1 101
1762 use1.3 0 101
1763 useOS this is test 101
1764 use2.1 0 101
............ ...... ..... ....
............ ...... ..... ....
............ ...... ..... ....
1850 use4.4 0 101
1851 use1.1 1 102
1852 use1.2 1 102
1852 use1.3 1 102
1853 useOS enter fun 102
1854 use2.1 0 102
............ ...... ..... ....
............ ...... ..... ....
............ ...... ..... ....
I wrote a query to transpose this based on user. There will be 90-100 coulmns per user..
Like following
---------------
User use1.1 use1.2 use1.3 .............. use4.4
------ -------- ------- -------- --------
101 0 1 0 ......... 0
102 0 1 1 ........ 1
...... etc
Here is the query I use
select "User" = x1.UserID,
max ( CASE when Item_ID = 1760 then x1.Code else "" end) as "1.1",
max ( CASE when Item_ID = 1761 then x1.Code else "" end) as "1.2",
max ( CASE when Item_ID = 1762 then x1.Code else "" end) as "1.3",
max ( CASE when Item_ID = 1763 then x1.Code else "" end) as "1.4",
max ( CASE when Item_ID = 1764 then x1.Code else "" end) as "1.2_Yes",
max ( CASE when Item_ID = 1765 then x1.Code else "" end) as "1.2_No",
max ( CASE when Item_ID = 1766 then x1.Code else "" end) as "1.2_OS1",
max ( CASE when Item_ID = 1767 then x1.Code else "" end) as "1.2_OS2",
max ( CASE when Item_ID = 1768 then x1.Code else "" end) as "1.31",
max ( CASE when Item_ID = 1769 then x1.Code else "" end) as "1.32",
max ( CASE when Item_ID = 1770 then x1.Code else "" end) as "1.33",
max ( CASE when Item_ID = 1771 then x1.Code else "" end) as "1.34",
max ( CASE when Item_ID = 1772 then x1.Code else "" end) as "1.35",
max ( CASE when Item_ID = 1773 then x1.Code else "" end) as "1.36",
max ( CASE when Item_ID = 1774 then x1.Code else "" end) as "1.37",
max ( CASE when Item_ID = 1775 then x1.Code else "" end) as "1.38",
max ( CASE when Item_ID = 1776 then x1.Code else "" end) as "1.39",
max ( CASE when Item_ID = 1777 then x1.Code else "" end) as "1.3_OS",
max ( CASE when Item_ID = 1778 then x1.Code else "" end) as "1.41",
max ( CASE when Item_ID = 1779 then x1.Code else "" end) as "1.42",
max ( CASE when Item_ID = 1780 then x1.Code else "" end) as "1.51",
max ( CASE when Item_ID = 1781 then x1.Code else "" end) as "1.52",
max ( CASE when Item_ID = 1782 then x1.Code else "" end) as "1.53",
max ( CASE when Item_ID = 1783 then x1.Code else "" end) as "1.54",
max ( CASE when Item_ID = 1784 then x1.Code else "" end) as "1.55",
max ( CASE when Item_ID = 1785 then x1.Code else "" end) as "1.56",
max ( CASE when Item_ID = 1786 then x1.Code else "" end) as "1.57",
max ( CASE when Item_ID = 1787 then x1.Code else "" end) as "1.58",
max ( CASE when Item_ID = 1788 then x1.Code else "" end) as "1.59",
max ( CASE when Item_ID = 1789 then x1.Code else "" end) as "1.510",
max ( CASE when Item_ID = 1790 then x1.Code else "" end) as "1.511",
max ( CASE when Item_ID = 1791 then x1.Code else "" end) as "1.5_OS",
max ( CASE when Item_ID = 1792 then x1.Code else "" end) as "2.11",
max ( CASE when Item_ID = 1793 then x1.Code else "" end) as "2.12",
max ( CASE when Item_ID = 1794 then x1.Code else "" end) as "2.21",
max ( CASE when Item_ID = 1795 then x1.Code else "" end) as "2.22",
max ( CASE when Item_ID = 1796 then x1.Code else "" end) as "2.23",
max ( CASE when Item_ID = 1797 then x1.Code else "" end) as "2.24",
max ( CASE when Item_ID = 1798 then x1.Code else "" end) as "2.2_OT1",
max ( CASE when Item_ID = 1799 then x1.Code else "" end) as "2.2_OS",
max ( CASE when Item_ID = 1800 then x1.Code else "" end) as "2.31",
max ( CASE when Item_ID = 1801 then x1.Code else "" end) as "2.32",
max ( CASE when Item_ID = 1802 then x1.Code else "" end) as "2.41",
max ( CASE when Item_ID = 1803 then x1.Code else "" end) as "2.42",
max ( CASE when Item_ID = 1804 then x1.Code else "" end) as "2.43",
max ( CASE when Item_ID = 1805 then x1.Code else "" end) as "2.44",
max ( CASE when Item_ID = 1806 then x1.Code else "" end) as "2.45",
max ( CASE when Item_ID = 1807 then x1.Code else "" end) as "2.46",
max ( CASE when Item_ID = 1808 then x1.Code else "" end) as "2.47",
max ( CASE when Item_ID = 1809 then x1.Code else "" end) as "2.48",
max ( CASE when Item_ID = 1810 then x1.Code else "" end) as "2.49",
max ( CASE when Item_ID = 1811 then x1.Code else "" end) as "2.4_OS",
max ( CASE when Item_ID = 1812 then x1.Code else "" end) as "2.5_OT",
max ( CASE when Item_ID = 1813 then x1.Code else "" end) as "3.11",
max ( CASE when Item_ID = 1814 then x1.Code else "" end) as "3.12",
max ( CASE when Item_ID = 1815 then x1.Code else "" end) as "3.13",
max ( CASE when Item_ID = 1816 then x1.Code else "" end) as "3.14",
max ( CASE when Item_ID = 1817 then x1.Code else "" end) as "3.15",
max ( CASE when Item_ID = 1818 then x1.Code else "" end) as "3.16",
max ( CASE when Item_ID = 1819 then x1.Code else "" end) as "3.17",
max ( CASE when Item_ID = 1820 then x1.Code else "" end) as "3.18",
max ( CASE when Item_ID = 1821 then x1.Code else "" end) as "3.19",
max ( CASE when Item_ID = 1822 then x1.Code else "" end) as "3.110",
max ( CASE when Item_ID = 1823 then x1.Code else "" end) as "3.111",
max ( CASE when Item_ID = 1824 then x1.Code else "" end) as "3.1_OS",
max ( CASE when Item_ID = 1825 then x1.Code else "" end) as "3.21",
max ( CASE when Item_ID = 1826 then x1.Code else "" end) as "3.22",
max ( CASE when Item_ID = 1827 then x1.Code else "" end) as "3.23",
max ( CASE when Item_ID = 1828 then x1.Code else "" end) as "3.24",
max ( CASE when Item_ID = 1829 then x1.Code else "" end) as "3.25",
max ( CASE when Item_ID = 1830 then x1.Code else "" end) as "3.26",
max ( CASE when Item_ID = 1831 then x1.Code else "" end) as "3.2_OS",
max ( CASE when Item_ID = 1832 then x1.Code else "" end) as "4.11",
max ( CASE when Item_ID = 1833 then x1.Code else "" end) as "4.12",
max ( CASE when Item_ID = 1834 then x1.Code else "" end) as "4.21",
max ( CASE when Item_ID = 1835 then x1.Code else "" end) as "4.22",
max ( CASE when Item_ID = 1836 then x1.Code else "" end) as "4.23",
max ( CASE when Item_ID = 1837 then x1.Code else "" end) as "4.24",
max ( CASE when Item_ID = 1838 then x1.Code else "" end) as "4.25",
max ( CASE when Item_ID = 1839 then x1.Code else "" end) as "4.26",
max ( CASE when Item_ID = 1840 then x1.Code else "" end) as "4.27",
max ( CASE when Item_ID = 1841 then x1.Code else "" end) as "4.28",
max ( CASE when Item_ID = 1842 then x1.Code else "" end) as "4.2_OS",
max ( CASE when Item_ID = 1843 then x1.Code else "" end) as "4.31",
max ( CASE when Item_ID = 1844 then x1.Code else "" end) as "4.32",
max ( CASE when Item_ID = 1845 then x1.Code else "" end) as "4.33",
max ( CASE when Item_ID = 1846 then x1.Code else "" end) as "4.34"
from tblQuest x1
group by x1.UserID
order by x1.UserID
Did this work for you?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OH oops JOIN is the CORRECT solution sorry about that :)
I knew you had to partition but I forgot you were using columns not rows... thus JOIN opposed to UNION was needed. Thanks.
Open in new window