Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Real Scripting 101

Status
Not open for further replies.

toetag

MIS
Sep 27, 2002
166
0
0
US
Up to now most of my SQL querying has been your basic:

select field from table where field = 'something'

I'm now in the position where i actually need to start doing conditional and math type scripts.

I've looked at scripts in the forums and on the web past few hours and I think i'm too deep to see the land.

Can anyone give an example script for something like the following:
Code:
get 80% of field1 as Condition1
get difference of field2 and field3 as Condition2
if Condition2 > than Condition1, return field4 and field5
i hope that makes sense. If i were writing a winform application, I could do this in code fairly fast.

Any assitance is greatly appreciated.

"The only desert to an Irishman is an empty glass".
 
What do you want to happen if the conditon is not met? Fill in a 0 instead or just not return any records where that happens?

Questions about posting. See faq183-874
Click here to help with Hurricane Relief
 
If it doesn't match the condition, it would be nice not to display anything. Just return the records that match the condition.

Thank you SQLSister!

"The only desert to an Irishman is an empty glass".
 
SQLSister,

real world keeping you busy? Not trying to rush, more just seeing if you still working on it is all.

"The only desert to an Irishman is an empty glass".
 
Something like this...

Code:
Select Field4, Field5
From   Table
Where  (Field3 - Field2) > (Field1 * 0.8)

If this isn't what you are looking for, try posting some sample data with expected results. It will help clarify your question and allow us to provide an acceptable answer in a timely fashion.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
gmmastros,

if it's as simple as that, i'm going to shoot myself.

i thought i'd have to Declare variables, loop through a query testing variables and matching conditions.

"The only desert to an Irishman is an empty glass".
 
Be careful with pistol :)
You could shoot someone else :)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top