Hi
I have been trying to solve these MS access SQL queries but unable to get the output . I have attached the query which I tried and the database structure for referencce..
Please help me in getting the correct answer asap !
Thanks !
Hi
I have been trying to solve these MS access SQL queries but unable to get the output . I have attached the query which I tried and the database structure for referencce..
Please help me in getting the correct answer asap !
Thanks !
1. UNION is certainly not appropriate. JOIN tables and apply filter criteria:
WHERE Publisher = "Vintage Books" OR Branch="JM Brentwood"
2. This requires aggregate (GROUP BY) subquery. JOIN appropriate tables and apply filter criteria:
WHERE Book_Code IN (SELECT Book_Code FROM Wrote GROUP BY Book_Code HAVING Count(*) = 2)
3. Again, a subquery can be used:
WHERE Branch_Num = JM Brentwood number AND Book_Code IN (SELECT Book_Code FROM Copy WHERE Branch_Num = JM on the Hill number)
4. This one gets complicated. First build a query of Copy that returns DISTINCT book codes for each branch. Then use that query to do an aggregate query that counts these DISTINCT records for each branch. Join that to Book and apply filter criteria:
WHERE CountOfBooks = (SELECT Max(CountOfBooks) FROM CountQuery)
There is possibility of a tie between branches for the most titles.
Hope that gets you in the right direction, pulling these from top of my head as no data available to test. Provide database with sample data if you want more help.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.