Showing posts with label distinct. Show all posts
Showing posts with label distinct. Show all posts

Tuesday, February 14, 2012

Create view

hi,if the below query
select DISTINCT group_module_menu_info.menulink FROM
user_group_role_info,group_role_module_info,group_ module_menu_info
where user_group_role_info.userid=user_table.userid and
((group_module_menu_info.moduleid = user_group_role_info.moduleid)OR
(user_group_role_info.roleid=group_role_module_inf o.roleid and
group_module_menu_info.moduleid = group_role_module_info.moduleid))

if i want to create a view
how ?
thank you!CREATE VIEW myviewname AS
select statement goes here

how hard did you try to look up the CREATE VIEW syntax?

:) :)|||hi,if the below query
select DISTINCT group_module_menu_info.menulink FROM
user_group_role_info,group_role_module_info,group_ module_menu_info
where user_group_role_info.userid=user_table.userid and
((group_module_menu_info.moduleid = user_group_role_info.moduleid)OR
(user_group_role_info.roleid=group_role_module_inf o.roleid and
group_module_menu_info.moduleid = group_role_module_info.moduleid))

if i want to create a view
how ?
thank you!

Create View <ViewName>
as
(Your Sql Statement)

Regards
Subramanyam.|||Create View <ViewName>
as
(Your Sql Statement)good one

looks a lot like post #2, though

:)|||Good answer.

Appears similar to post #2, however.|||Good answer.

Appears similar to post #2, however.that's funny, your post looks a lot like post #4

;) ;)

create view

CREATE VIEW getUsedColumns AS SELECT * FROM (SELECT DISTINCT attr FROM iba UNION SELECT DISTINCT attr FROM new_iba) WHERE attr != 0;

its working with oracle

how to chenge in t-sql

thanx

Hi,

you have to ALIAS Your SubQuery.

CREATE VIEW getUsedColumns
AS
SELECT * FROM
(
SELECT DISTINCT attr
FROM iba
UNION
SELECT DISTINCT attr
FROM new_iba
) SomeSubQuery
WHERE attr != 0;

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

|||

You need to specify an alias for the derived table. And you don't really need the DISTINCT in each of the SELECT statements since the UNION will eliminate the duplicates anyway. You will get better performance by writing it as:

SELECT * FROM (SELECT Dattr FROM iba UNION SELECT attr FROM new_iba) as t

WHERE attr != 0;