Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 can you give logic for this....

Author  Topic 

nvakeel
Yak Posting Veteran

52 Posts

Posted - 2008-02-13 : 10:42:12
Tbl1
----
Valve1 Valve2
------ --------
Buttefly......Keystone
Kite...........Mouse
Eno............Pad

Tbl2
----

Priority Valve
------ ------
1............Butterfly
2............Kite
3............Eno

Tbl3
-----

Group1 Group2 Group3
------ ------ ------
All..........Eno.......All
Butterfly......All......Kite
Eno............None......All

Now my logic should return

valve1 should fall in Group1 because group 1 holds All,Butterfly, eno
and All can accomodate any of the attributes of the valve.

If in Group1 All,Eno,None then valve1 should fall in group3.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-13 : 10:49:40
How do you want your result presented?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nvakeel
Yak Posting Veteran

52 Posts

Posted - 2008-02-13 : 11:19:52
valve1--groupname--priority
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-13 : 11:52:12
How do Tbl2 with priorities come into the picture?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-13 : 11:53:14
[code]-- Prepare sample data
DECLARE @Tbl1 TABLE (Valve1 VARCHAR(20), Valve2 VARCHAR(20))

INSERT @Tbl1
SELECT 'Butterfly', 'Keystone' UNION ALL
SELECT 'Kite', 'Mouse' UNION ALL
SELECT 'Eno', 'Pad'

DECLARE @Tbl2 TABLE (Priority TINYINT, Valve VARCHAR(20))

INSERT @Tbl2
SELECT 1, 'Butterfly' UNION ALL
SELECT 2, 'Kite' UNION ALL
SELECT 3, 'Eno'

DECLARE @Tbl3 TABLE (Group1 VARCHAR(20), Group2 VARCHAR(20), Group3 VARCHAR(20))

INSERT @Tbl3
SELECT 'All', 'Eno', 'All' UNION ALL
SELECT 'Butterfly', 'All', 'Kite' UNION ALL
SELECT 'Eno', 'None', 'All'[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-13 : 12:25:51
How do you relate the three tables to each other?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nvakeel
Yak Posting Veteran

52 Posts

Posted - 2008-02-13 : 12:57:21
i think this is a bad example.. let me come up with good one.
Thanks for the patience.
Go to Top of Page
   

- Advertisement -