By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

how to select a table that has most columns using syscat?

P: n/a
hello,

how to select a table that has a highest amount of columns (compared
to other tables) using syscat?

thanks in advance

May 22 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Ian
d0m_at0m wrote:
hello,

how to select a table that has a highest amount of columns (compared
to other tables) using syscat?
I can't imagine how this would be useful, but:

select tabschema, tabname, count(*) as num_cols
from syscat.columns
group by tabschema, tabname
order by 3 desc
fetch first 1 row only;

May 22 '07 #2

P: n/a
On May 23, 4:30 am, d0m_at0m <2lazy2sl...@gmail.comwrote:
hello,

how to select a table that has a highest amount of columns (compared
to other tables) using syscat?

thanks in advance
even this may work i think ..

select * from syscat.tables
where colcount=(select max(colcount) from syscat.tables)

May 23 '07 #3

P: n/a
On May 23, 4:54 am, Ian <ianb...@mobileaudio.comwrote:
d0m_at0m wrote:
hello,
how to select a table that has a highest amount of columns (compared
to other tables) using syscat?

I can't imagine how this would be useful, but:

select tabschema, tabname, count(*) as num_cols
from syscat.columns
group by tabschema, tabname
order by 3 desc
fetch first 1 row only;
even it may work i think ..

select * from syscat.tables
where colcount=(select max(colcount) from syscat.tables)

May 23 '07 #4

P: n/a
situ wrote:
On May 23, 4:54 am, Ian <ianb...@mobileaudio.comwrote:
>d0m_at0m wrote:
hello,
how to select a table that has a highest amount of columns (compared
to other tables) using syscat?

I can't imagine how this would be useful, but:

select tabschema, tabname, count(*) as num_cols
from syscat.columns
group by tabschema, tabname
order by 3 desc
fetch first 1 row only;

even it may work i think ..

select * from syscat.tables
where colcount=(select max(colcount) from syscat.tables)
SELECT *
FROM syscat.tables
ORDER BY colcount DESC
FETCH FIRST 1 ROW ONLY

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
May 23 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.