Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help about Where Clause
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01012198
Message ID:
01012784
Views:
38
Hi Nick,

Would this query work for you?
SELECT T1.code, T1.descr, T1.PercIVA, T1.PercIND, T1.IvaCEE 
	FROM T1
	WHERE T1.IvaCEE IS NOT NULL
		AND (T1.PercIND <> 0 
			OR NOT EXISTS (SELECT * FROM t1 T12 
				WHERE T12.code = t1.IvaCEE AND t12.PercIVA = t1.PercIVA))
>
>Yes, I clarify the problem.
>
>My table has i.e the above structure:
>
>==============================
>CREATE TABLE dbo.T1
>(
> Code    CHAR(3) NOT NULL,
> Descr   CHAR(30),
> PercIVA NUMERIC (5, 2),
> PercIND NUMERIC (5, 2),
> IvaCEE  CHAR(3)
>)
>GO
>
>INSERT dbo.T1 VALUES ('abc', 'Test1', 10.0, 10.0, NULL)
>INSERT dbo.T1 VALUES ('def', 'Test2', 20.0, 0.0, NULL)
>INSERT dbo.T1 VALUES ('ghi', 'Test3', 0.0, 0.0, NULL)
>INSERT dbo.T1 VALUES ('lmn', 'Test4', 10.0, 10.0, NULL)
>INSERT dbo.T1 VALUES ('opq', 'Test5', 10.0, 0.0, 'abc')
>INSERT dbo.T1 VALUES ('rst', 'Test6', 10.0, 5.0, 'abc')
>INSERT dbo.T1 VALUES ('uvz', 'Test7', 0.0, 0.0, 'abc')
>INSERT dbo.T1 VALUES ('xyw', 'Test8', 0.0, 15.0, 'abc')
>GO
>
>1) Test1, Test2, Test3, Test4 are correct, because IvaCEE is NULL.
>2) Test4 is correct, because IvaCEE is filled by Test1, that has
> a) Its PercIva = Perciva of Test1 PercIva
> b) Its PercIND is = ZERO
>3) Test6, Test7 and Test8 are incorrect, because the condition a) and b) are not respected.
>
>I need to validate the field IvaCEE, in order to respect the clause a) and b) when this field is filled.
>I manage my form with a Cursor Adapter for my MSSQL Table, with a select and a cursor schema like these:
>SELECT T1.code, T1.descr, T1.PercIVA, T1.PercIND, T1.IvaCEE from T1
>CODE C(3), DESCR C(30), PERCIVA N(5,2), PERCIND N(5,2), IVACEE C(3)
>
>I have had a suggestion to create a second cursor with a Where clause for the table in order to control the validity of PercIVA Field.
>But I don't know if it is the better method, and how to create it exactly.
>
>Sorry for my poor english, but I hope to have clarify the problem.
>
>Thank You and Best Regards
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform