Quantcast
Channel: SCN : Discussion List - SAP BusinessObjects Web Intelligence
Viewing all articles
Browse latest Browse all 5402

creating subquery in select clause

$
0
0

Hi,

 

I want to recreate the below query in my WEBI report.

 

select

COUNT(LIBRARY.BOOKID)  AS Total_BOOKS,

 

(select COUNT(EXEMPT_BOOK.BOOKID)

from

LIBRARY EXEMPT_BOOK

WHERE EXEMPT_BOOK.BOOK_ID=LIBRARY.BOOK_ID

AND EXEMPT_BOOK.EXEMPTED ='Y') AS TOTAL_EXEMPTED_BOOKS,

 

(select COUNT(EXPIRED_BOOK.BOOKID)

from

LIBRARY EXPIRED_BOOK

WHERE EXPIRED_BOOK.BOOK_ID=LIBRARY.BOOK_ID

AND EXPIRED_BOOK.EXPIRED='Y') AS TOTAL_EXPIRED_BOOKS

 

from LIBRARY

 

The above query returns 3 attributes-

Total_BOOKS--     COUNT of total books in LIBRAY TABLE

TOTAL_EXEMPTED_BOOKS-- Count of exempted books in LIBRAY TABLE

TOTAL_EXPIRED_BOOKS-- Count of expired books in library table.

 

Please help me in choosing the best method to recreate the query in Universe so that the above query can be retrieved in WEBI.

 

One option that i can think of is add table LIBRARY in universe and then add 2 aliases --EXEMPT_BOOK and EXPIRED_BOOK and join them to LIBRARY using LEFT OUTER JOIN.

So the generated query in WEBI will be

 

SELECT COUNT (LIBRARY.BOOKID) AS Total_BOOKS,

        COUNT (EXEMPT_BOOK.BOOKID)  AS TOTAL_EXEMPTED_BOOKS,

         

    COUNT (EXPIRED_BOOK.BOOKID) AS TOTAL_EXPIRED_BOOKS

  FROM LIBRARY

  left outer join  LIBRARY EXEMPT_BOOK

             on EXEMPT_BOOK.BOOK_ID = LIBRARY.BOOK_ID

   left outer join  LIBRARY  EXPIRED_BOOK

        EXPIRED_BOOK.BOOK_ID = LIBRARY.BOOK_ID    

WHERE

EXEMPT_BOOK.EXEMPTED = 'Y'

AND EXPIRED_BOOK.EXPIRED = 'Y'

 

But is there any better method than the above?

 

Regds,

Samson


Viewing all articles
Browse latest Browse all 5402

Trending Articles



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