Monday, October 29, 2012

While Select



CustTable custTable;
while select accountNum, name, address from custTable
{
print custTable.AccountNum, " ", custTable.Name, " ",
custTable.Address;
pause;
}
_________________________________________________________________________________

CustTable custTable;
;
while select custTable
where custTable.AccountNum > "4005"
&& custTable.AccountNum < "4017"
{
print custTable.AccountNum , " ",custTable.Name;
}
pause;
_________________________________________________________________________________
//Sorting Obtion index

CustTable custTable;
;
while select custTable index AccountIdx
{
print custTable.AccountNum, " ", custTable.Name;
}
pause;

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 //ORDER BY


CustTable custTable;
;
while select custTable order by AccountNum desc
{
print custTable.AccountNum, " ", custTable.Name;
}
pause;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

//GROUP BY
SalesTable salesTable;
;
while select count(salesid) from salesTable group by
CustGroup
{
print salesTable.CustGroup," ",salesTable.salesid;
}
pause;

_________________________________________________________________________________
//Aggregate
sum -->Returns the sum of the values in a field.
avg -->Returns the average of the values in a field.
maxof -->Returns the maximum of the values in a field.
minof -->Returns the minimum of the values in a field.
count -->Returns the number of records that satisfy the statement. Count can only be used on numerical fields, since the result will be returned in that field.



select sum(amountMST) from ledgerTrans;
sumAmountMST = ledgerTrans.amountMST;
select count(recId) from ledgerTrans;
countLedgerTrans = ledgerTrans.recId;





_________________________________________________________________________________



No comments: