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.
Author |
Topic |
yguyon
Starting Member
11 Posts |
Posted - 2015-02-05 : 12:15:14
|
Table F4801WADOCO / WARCTO/ WAPARS / WASRST /WARORN2 / JT / / 5 / 0324 / JT / 05 / 10 / 032 5 / JT / 03353 / 10 / 0323353 / JT / 04 / 10 / 0322323 / JT / 02323 / 10 / 032From the table I want to return a set of record 2, 4, 5, 3353, 2323 from the column WADOCO2 is the parents and 4,5,3353,2323 is the childThe query should meet the following requirement to return WADOCO = 2WACTO = 'JT'WASRST = '05'and WAPARS = ' 'This is a simple select statement.Select WADOCO from table XXXwhere WACTO = 'JT'and WASRST = '04'and WAPARS = ' 'The difficult part is to return the child of 2 such as 4, 5, 3353, 2323 And the child should meet the following requirementWASRST >= '09'WASRST <= '10'and the value of WAPARS in the child exist in the column of WADOCOHow do I try to combine two querry in one. I tried the following querry but no luck.with ctweg as (select WARORN from F4801where WAPARS IN (SELECT WADOCO FROM F4801)AND WASRST >= '02'AND WASRST <= '05') select * FROM F4801 WHERE WARCTO = 'JT' AND WAPARS = ' ' AND WASRST >= '09' AND WASRST <= '10' AND WARORN = ( SELECT * FROM ctweg) |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2015-02-05 : 18:46:54
|
How do you know which record is he child of another? How do you know which record is a root parent? Those who will not reason, are bigots, those who cannot, are fools, and those who dare not, are slaves. -Lord Byron, poet (1788-1824) |
|
|
yguyon
Starting Member
11 Posts |
Posted - 2015-02-06 : 10:42:58
|
quote: Originally posted by Bustaz Kool How do you know which record is he child of another? How do you know which record is a root parent? Those who will not reason, are bigots, those who cannot, are fools, and those who dare not, are slaves. -Lord Byron, poet (1788-1824)
How do I know how to tell wich one is the parent and wich one is the child.The parent such as 2(WADOCO) as a value of WAPARS = ' 'And the child its value in the WAPARS columns exist in the WADOCO column. As an example the value of 4 will have a value in WAPARS of 86 that exist in the WARORN column of 2Here is a better explanation WADOCO - WAPARS - WARORN2 - ' ' - 8633 - 89 - 984 - 86 - 78 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2015-02-06 : 16:23:32
|
All of the WARORN values are "032" for the entire table. Here is the data you presentedWADOCO /WARCTO /WAPARS /WASRST /WARORN2 / JT / "" / 5 / 0324 / JT / 05 / 10 / 0325 / JT / 03353 / 10 / 0323353 / JT / 04 / 10 / 0322323 / JT / 02323 / 10 / 032 I don't see half of the values you mention (89, 86, 98, 78, etc.) Those who will not reason, are bigots, those who cannot, are fools, and those who dare not, are slaves. -Lord Byron, poet (1788-1824) |
|
|
|
|
|
|
|