Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

PL/SQL queries to return different records

$
0
0

Hi all,

I used the 1st query into 2nd one when counting the commission as following:

1.

SELECT DISTINCT tblCustomer.Name, tblCustomer.JobType, tblSale.Unit, tblSale.Price
FROM tblCustomer, tblSale
WHERE tblCustomer.id = tblSale.customerid;

2. 

SELECT b.Name, 
(CASE WHEN b.JobType = "FULL TIME" THEN ((b.Unit * b.Price) * 0.25) 
WHEN b.JobType = "PART TIME" THEN ((b.Unit * b.Price) * 0.15)
END) AS b.Commission
FROM (SELECT DISTINCT tblCustomer.Name, tblCustomer.JobType, tblSale.Unit, tblSale.Price
            FROM tblCustomer, tblSale
            WHERE tblCustomer.id = tblSale.customerid) b
);

I use the COUNT(*) for both above queries, there are more records on 2nd query. My expectation are produced same records for both queries. Do you know why and how to correct the syntax on them. Thanks.  


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>