I'm sorry if this is a bit of a silly question - I'm not too familiar with using SQL or database queries in general.
I have a field "D:Morphology" which is populated by codes beginning with a letter and followed by a 5 digit number (e.g M80000). I also have a "D:Topography" field which functions in more or less the same way.
I need a query to return:
All values for D:Morphology beginning with M8 or M9 AND ending in 1-9
or
All values for D:Morphology ending in 0 IF D:Topography begins with T91
or
All values for D:Morphology ending in 0 IF D:Topography begins with T92
or
All values for D:Morphology ending in 0 IF D:Topography begins with TX (EXCEPTTX05-TX07)
or
D:Morphology is equal to M49000 AND D:Topography begins with T06
or
D:Morphology is equal to M:74008 OR M74009 OR M72860
if anyone could help me form this query or point me in the direction to best learn how to do this myself, I would really appreciate it.
David
Page 1 / 1
I'm sorry if this is a bit of a silly question - I'm not too familiar with using SQL or database queries in general.
I have a field "D:Morphology" which is populated by codes beginning with a letter and followed by a 5 digit number (e.g M80000). I also have a "D:Topography" field which functions in more or less the same way.
I need a query to return:
All values for D:Morphology beginning with M8 or M9 AND ending in 1-9
or
All values for D:Morphology ending in 0 IF D:Topography begins with T91
or
All values for D:Morphology ending in 0 IF D:Topography begins with T92
or
All values for D:Morphology ending in 0 IF D:Topography begins with TX (EXCEPTTX05-TX07)
or
D:Morphology is equal to M49000 AND D:Topography begins with T06
or
D:Morphology is equal to M:74008 OR M74009 OR M72860
if anyone could help me form this query or point me in the direction to best learn how to do this myself, I would really appreciate it.
David
I have a field "D:Morphology" which is populated by codes beginning with a letter and followed by a 5 digit number (e.g M80000). I also have a "D:Topography" field which functions in more or less the same way.
I need a query to return:
All values for D:Morphology beginning with M8 or M9 AND ending in 1-9
or
All values for D:Morphology ending in 0 IF D:Topography begins with T91
or
All values for D:Morphology ending in 0 IF D:Topography begins with T92
or
All values for D:Morphology ending in 0 IF D:Topography begins with TX (EXCEPTTX05-TX07)
or
D:Morphology is equal to M49000 AND D:Topography begins with T06
or
D:Morphology is equal to M:74008 OR M74009 OR M72860
if anyone could help me form this query or point me in the direction to best learn how to do this myself, I would really appreciate it.
David
If you want to work this out using the CorVu: CorBusiness formula language then the example below should work. A CorVu formula is applied to data AFTER it has been extracted from the data source. If you want the formula to apply AS the data is being searched in the database, then you have to use the database query language (e.g. SQL) or use the CorVu Query design view to select the columns then use the Add Complex Conditions function which would require a LOT of fiddly box ticking and a lot of bracketing!
Using a CorVu formula:
Open your data set and select menu option Data>Filter Query
Select filter type as Free style compound condition filter, and it will open the formula box in the Filter query Wizard.
Paste in the following CorVu formula:
M = @[D:Morphological];T = @[D:Topographical];A1 = in(left(M,2),'M8','M9') && in(right(M,1),1,2,3,4,5,6,7,8,9) ;A2 = right(M,1) == 0 ? in(left(T,3),'T91','T92') || ( left(T,2)== 'TX' && not(in(left(T,4),'TX05','TX06','TX07')));A3 = M == 'M49000' && left(T,3) == 'T06';A4 = in(M,'M74008', 'M74009', 'M72860');A1 ? 1 : A2 ? 1 : A3 ? 1 : A4explanation:
The current row values of the 2 columns to be checked are temporarily stored in the runtime variables M and T. This is to make the formula easier to read. (You could do the same by creating new columns to hold results but it is not always necessary).
I parceled your conditions into into 4 logical statements and assigned the results to runtime variables A1 to A4
If a condition is true then the result is 1 and this gets stored in the assigned runtime variable.
Finally it checks the result of each variable in order from A1 to A4, so if any are 1 (true) then the row being tested is returned.
The last line basically means - if result of A1 is true then keep the row else if the result of A2 is true then keep the row else if ..etc..
With this method you can edit the formula and remove conditions one by one to test the results
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.