How many books have been purchased along with their quotations in the month of Jan 2010, in order to aggregated values from different table following is an easy way to do it.
Select count(b.book_id) as "Total Books"
,(Select count(q.id)
from tbl_q_received as "q"
where date_format(b.purchase_date,'%y-%m-d')=date_format(b.purchase_date,'%y-%m-d')) as "Total Quotations"
from tbl_book b
where b.purchase_date between '2010-01-01 00:00:00' and '2010-01-3123:59:59'
Labels
- AVG() Function (1)
- Aggregate Functions (1)
- Candidate Key (1)
- Composite and Compound Keys (1)
- EXISTS (1)
- FIRST() Function (1)
- Group By Statement (1)
- Having Clause (1)
- INSERT (1)
- LIKE (1)
- SELECT AS CLAUSE (1)
- SQL Distinct Unique Records (1)
- SQL IN (1)
- SQL Joins (1)
- SQL Last() Function (1)
- SQL NULL Conditional (1)
- SQL Not Exists (1)
- SQLComparison Operators (1)
- Sql Max() Function (1)
- Sql Min() Function (1)
- Sql SUM() Function (1)
- WHERE (1)
Blog Archive
-
▼
2010
(73)
-
▼
March
(7)
- ROW_NUMBER() window function
- Select statement to Extract text file in a column ...
- Select Column Level Fields from more than one table
- How to Choose Date Format in MYSQL
- Single Insertion for all values in ETL script
- Hour Basis Records from Transactional Databases to...
- Setting and Getting varibles in Pentaho Transforma...
-
▼
March
(7)
Tuesday, March 23, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment