Knowledgebase
[QODBC-Desktop] How to use SQL functions in QODBC
Posted by Rajendra Dewani (QODBC Support) on 14 April 2014 04:01 PM

QODBC does support standard SQL queries, but the function is implemented differently.

Please refer to the functions below & try to execute them in QODBC Test Tool.

Functions in Select Query:

You can use distinct like:

SELECT DISTINCT CustomerRefFullName FROM InvoiceLine

Please refer to the article below for more information:
QODBC Function-List

You can use SubQuery in QODBC like:

SELECT * from customer WHERE TimeModified IN (SELECT TimeModified from customer WHERE TimeCreated < {ts '2007-06-17 00:00:00.000'})

 

SELECT * from customer WHERE ListID IN (SELECT CustomerRefListID  from Invoice WHERE TimeCreated > {ts '2026-06-17 00:00:00.000'})

 

Group By

select txndate, sum(subtotal) as AmountDateWise  from Invoice group by txndate

 

Function Sub with Date Range

select txndate, sum(subtotal) as AmountDateWise  from Invoice where TimeCreated  >= {ts '2003-01-01 00:00:00.000'} and TimeCreated  <= {ts '2035-01-01 00:00:00.000'} group by txndate

 

SELECT Customer.CompanyName, Customer.FullName,  SUM(Invoice.Subtotal) AS TotalAmount, SUM(Invoice.SalesTaxTotal) AS TotalTax FROM
Invoice, Customer WHERE Invoice.CustomerRefFullName= Customer.FullName and Invoice.txndate>={d'2001-07-20'} and Invoice.txndate<={d'2036-07-20'} GROUP BY Customer.CompanyName, Customer.FullName

 

SELECT Customer.CompanyName, Customer.FullName, SUM(Invoice.Subtotal) AS TotalAmount, SUM(Invoice.SalesTaxTotal) AS TotalTax,
Customer.Balance, CASE WHEN Customer.Balance > 10500 THEN 'HIGH' WHEN Customer.Balance > 3000 and Customer.Balance<=10500 THEN 'MED' WHEN Customer.Balance >0 and Customer.Balance<=3000 THEN 'LOW' ELSE '--NA--' END FROM Invoice, Customer WHERE Invoice.CustomerRefFullName = Customer.FullName and Invoice.txndate>={d'2001-07-20'} and Invoice.txndate<={d'2036-07-20'} GROUP BY Customer.CompanyName, Customer.FullName, Customer.Balance

Functions in Update Query:

You can replace functions in the Update query like:

UPDATE TableName SET ColumnName = {fn REPLACE("ColumnName",'ValueToFind','ValueToReplace')} WHERE (condition)

For Example:

UPDATE Invoice SET RefNumber = {fn REPLACE("RefNumber",'71047','0777')} WHERE (TxnDate>{d '2012-12-31'})

You can change the table name & column name as per your requirement.

(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please complete the captcha below (we use this to prevent automated submissions).