Subject | [firebird-support] Re: Data in Row Format, Need To Display In Columun Format |
---|---|
Author | Svein Erling Tysvær |
Post date | 2010-09-08T08:52:01Z |
>Hi SET,Hi again Vishal!
>
>Sorry it might be because I am not good enough with sql, asking you last doubt that do I need to use your entire sql as it i.e. WITH and next SELET is
>like:
>
>WITH Branches(BranchCode) as
>(SELECT DISTINCT sBranchCode
>FROM Book_Details
>WHERE (sYearMonth = :YearMonthA or sYearMonth = :YearMonthB)
>AND BookName in(:MyFirstBookName, :MySecondBookName)
>)
>SELECT B.BranchCode, BD1A.rBook_Price as Book1PriceYearMonthA, BD1B.rBook_Price as Book1PriceYearMonthB,
>coalesce(BD1A.iCopy_Sold, 0) - coalesce(BD1B.iCopy_Sold, 0) as Book1CopySoldDifference,
>coalesce(BD1A.Tot_Amount, 0) - coalesce(BD1B.Tot_Amount, 0),
>BD2A.rBook_Price, BD2B.rBook_Price, coalesce(BD2A.iCopy_Sold, 0) -
>coalesce(BD2B.iCopy_Sold, 0),
>
>....CONTINUE WITH YOUR SQL
If I understand this question correctly, then the answer is yes, you need both the WITH part (including SELECT) and the SELECT part. Think of the WITH as a way to create a temporary table that you can use in your main select.
As I said in my last reply, it is possible to avoid WITH in your query, but that would make the query more complex.
Set