Grand Total Is Showing Wrong Result

May 19, 2008



My FactEmployeeTable showing 13 rows of data related to employees, but i used a bridge table for connecting project and employee dimensions. In the ProjEmpBridge table i mapped only 6 employees data to the proj's data. When dragging projet name and employee name it is showing data related to 6 employees but grand total showing 13 as the result. I dont know why it is showing 13 instead of 6. Can anyone please solve this issue.

View 10 Replies


ADVERTISEMENT

Role Defined Wrong Grand Total Result

May 22, 2008



HI,

In my cube I have defined a role where thet user can only browse certain dimention value. BUt in grand Total the result showing is for all the diemnsion values.

for example The user restricted to browse only Australia and UK Country , But in grand total its showing the SUM of all the country.

Any help will be appreciated.

Thanks

View 3 Replies View Related

Transact SQL :: Grand Total At Button Of Result Set Of Query

Jul 16, 2015

I have a script that produce a result set that is almost complete. I have a new requirement come up to put a Total  at the button of the result set of my Query.

I'm using SQL Server 2008
;WITH CTE AS
(
SELECT
Case WHen left(MONTHDate,3)='Jan' Then '01'
WHen left(MONTHDate,3)='Feb' Then '02'
WHen left(MONTHDate,3)='Mar' Then '03'
WHen left(MONTHDate,3)='Apr' Then '04'
WHen left(MONTHDate,3)='May' Then '05'

[code]....

View 4 Replies View Related

Grand Total

Oct 18, 2007



Hello All,
I've created a report that has a count of dates reports. Every company has at least one date report. I've group the report by company and did a count this works find. Now I want to SUM up this field and put it at the end of the report.
I've used =sum(reportitems!textbox10.value) but it only works at the page footer. And only give me a grand total for that page. I want a grand total for the whole report. Is there a report footer???

Thanks
Set_Shot_Dave

View 2 Replies View Related

Get The Grand Total Of This Query

Dec 12, 2003

I need to get the Grand Total of the results of this query.
The query pulls the total customer quotes for each community in a management company and loads my DataGrid:

This query works fine for individual community totals"SELECT TOP 100 PERCENT vcName, COUNT(DISTINCT vcCustId) AS " & _
" Total FROM dbo.PropReportData WHERE cManagementCo = '" & Session("MgmtCo") & "' and " & _
" (vcEntryDate >= CONVERT(DATETIME, '" & StartDate & "', 102)) AND " & _
"(vcEntryDate <= CONVERT(DATETIME, '" & EndDate & " 11:59:59 PM" & "' , 102))GROUP BY vcName ORDER by vcName"

At first glance you would think that the following query would return the Grand Total for all communities in the management company:

Current Grand Total Query"SELECT COUNT(DISTINCT vcCustID) As gTotal FROM PropReportData WHERE
cManagementCo = '" & Session("MgmtCo") & "' AND vcEntryDate >= '" & Session
("StartDate") & "' AND vcEntryDate <= '" & Session("EndDate") & " 11:59:59 PM' "

But here's the problem. If there are multiple customer quotes created for different communites, then the customer(vcCustID) is only counted once in the Grand Total Query because I have to use DISTINCT, which of course only picks up one instance of the customer.

Thanks in advance.

View 2 Replies View Related

Grand Total Needed

Jan 18, 2007

I have two subreports (Revenue and Expense) that each have subtotals.

This works just fine, but I need a Grand Total that would sum the two subtotals.

How would I go about doing this?



So it looks something like this:



Revenue Report (matrix)

Subtotal

Expense Report (matrix)

Subtotal

<~~~~ Need Grand Total here.

View 18 Replies View Related

How To Arrive At Grand Total?

Mar 6, 2007

Hi All,

My doubt is, how to get gand total in SQL Reporting Services2005 for the following scenario?

Sample report content:

CustomerId Product Name Price

123 Apple $100.00

Orange $77.00

SUB TOTAL $177.00

124 Apple $105.00

Orange $70.00

Olive $450.00

SUB TOTAL $625.00 // sum(Fields!Price)

GRAND TOTAL $802.00 //How to get Grand total? please..

Regards,

Pragash

View 6 Replies View Related

Grand Total Problem

Aug 5, 2007

Hi,

I am trying to calculate grand totals in the table footer area on a single table report. The report table has a grouping with a filter. I want the grand total to sum the visible grouping data but instead it sums the entire dataset. I've tried summing the textbox but RS does not allow that from the footer. I've tried specified the group for the scope but apparently RS scope works outward not inward in regards to groups. A simple example of my problem might be a list of bank accounts whose balance is overdrawn. In the report you want to show only the accounts whose balance has gone negative and all the transactions for those accounts. You can create a group on the account field and then a filter on the group to sum the transaction amount and filter out the accounts whose sum is not below zero. The grand total would supposedly sum the accounts whose balance is negative. Unfortunately the sum is on the entire dataset and therefore includes accounts with good balances. I'm sure some will suggest changing the SQL but that is not an option for me. These seems like a very basic operation for a report writer so I'm guessing there is some easy way to do this that has eluded me. Thanks for any help.

View 15 Replies View Related

Calculate Grand Total Using Pivot

Apr 25, 2014

How to calculate grand total in sql server using pivot?

View 1 Replies View Related

Combined Orders Grand Total?

Apr 20, 2007

Hi,

Im using Access and have created a query which adds up the grand totals of clients orders. However i want to be able to add up what each client has spent in total over any given time period. Basically in SQL logic terms:

take all order totals from same client and add together order totals to produce a grand client spend total.

Anyone help!?

thanks

View 3 Replies View Related

Group Subtotal And Grand Total

Jun 12, 2007

how to add group subtotal and grand total in report? i try to add formula Sum(Field!Net_Weight.Value) in group footer and unable repeat footer on each page, it return same total on every pages. I hope to get subtotal on each page by group. the expected result would be like this:









Page1












1.Group 1





Date
D/no
Net Weight

6/1/2007
A00000100
10.45

6/1/2007
A00000101
10.95

6/1/2007
A00000102
11.45

6/1/2007
A00000103
11.95

6/1/2007
A00000104
12.45

6/1/2007
A00000105
12.95



Subtotal
70.2








Page 2












Date
D/no
Net Weight

6/1/2007
A00000100
20.15

6/1/2007
A00000101
20.25

6/1/2007
A00000102
20.35

6/1/2007
A00000103
20.45

6/1/2007
A00000104
12.45

6/1/2007
A00000105
12.95



Subtotal
106.6










Grand Total=
176.8















2.Group 2





Date
D/no
Net Weight

6/1/2007
A00000100
10.45

6/1/2007
A00000101
10.95

6/1/2007
A00000102
11.45

6/1/2007
A00000103
11.95

6/1/2007
A00000104
12

6/1/2007
A00000105
12.95



Subtotal
69.75
anybody know how to do it?

View 3 Replies View Related

Calculating Grand Total And Percentage

Oct 19, 2007

Hi All,

I have to create a table like this using SSRS.

LoanStatus NoOfLoans Amouunt Percentage









Started
1,000
1,000,000.00
100%









Sent to Partner
350
350,000.00
35%

Denied by Partner
50
50,000.00
5%

Accepted by Partner
300
30,000.00
30%

Loan Apps Pnd Disb
10
100,000.00
1%

Loan Apps Disbursed
290
290,000.00
29%




Table is grouped by loan status.
Percentage is calculate as NoOfLoans/TotalNoOfLoans.


Please can anyone tell me how to calculate the grand total and Percentages?

View 5 Replies View Related

Add Grand Total At Bottom Of Pivot Table?

Nov 9, 2013

I've been messing around with ROLLUP but have got nowhere,I have this:

DECLARE @sql NVARCHAR(MAX)
DECLARE @pivotsql VARCHAR(MAX)
DECLARE @columns VARCHAR(MAX)
DECLARE @selectlist VARCHAR(MAX)

[code]...

which works a treat - I just need a grand total at the bottom for each column.

View 7 Replies View Related

Analysis :: Custom Grand Total In SSAS?

Jul 23, 2015

I have a requirement where I need to show the maximum value in grand totals but for the dimension members the same measure has to sum.

For ex: lets say I have a measure called Test and this is a base measure. The aggregation type set  to this is SUM.

For this same measure the grand totals should not show the sum instead it should show the maximum value of the dimension members which is being analyzed across.

View 4 Replies View Related

Transact SQL :: Add A Grand Total To Pivot Output?

Oct 9, 2015

I have a SP that will generate a pivot output. I want to add a grand total at the end row to sum up the counts for each column.

the SP is as below :

/* COLUMN HEADERS*/
DECLARE
@columnHeaders NVARCHAR (MAX)
SELECT
@columnHeaders  =  COALESCE ( (@columnHeaders)  + ',[' + [Date] + ']', '[' + [Date] + ']')

[code]....

I am getting the below error:

Invalid column name 'Grand Total'.

Msg 205, Level 16, State 1, Line 16

All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.

View 10 Replies View Related

Matrix Report Columns Grand Total

Sep 10, 2007

Hi There i have a Report That Display's data in following format


Areas
Code | Descirption | Emirates | GCC | ASIAN | OTHER ARABS | so on..
1 What ever 3 0 2 1
2 ABC 0 0 1 0
-------------------------------------------------------------------------------------------
Total 3 0 3 1


The Areas are Matric Columns and are dynamically generated .

i dont want sub total of each row , but i want Grand total at the end of the all columns generated by matrix

I have no clue how do to it


Kind Regards

View 7 Replies View Related

Grand Total Column In Matrix Report

Jan 15, 2008

Hi,
Hi All,

I am having some trouble getting a Grand Total column at the end of my matrix report (not row at the bottom), such as you get by default in an Excel pivot table.

I have managed so far to add another column that sums up all values across the data range for a particular product code. My intention was to hide all but the last (I did something similar on rows). However you cannot use an expression on the width property for columns, so this will not work.

My report is very standard:
Year
Month (grouped by year)
Product code | Description [qty]


I want a column that displays the total qty across all dates for each row. Surely this is possible?

Any suggestions would be appreciated! Thanks.

View 6 Replies View Related

Distinct Count With Null Values (grand Total)

May 9, 2007

Hello,

I have a DB of professors and information related with them. I created the cube, it consist of:
Measures:
Measure group Professors:
Amount of projects (COUNT proj_id)
Amount of pulications (COUNT pub_id)
Amount of e_books (COUNT book_id)
--------------
Measure group Projects:
Distinct amount of projects (DISTINCT COUNT proj_id)
--------------
Measure group Publications:
Distinct amount of publications (DISTINCT COUNT pub_id)
--------------
Measure group E_books:
Distinct amount of e_books (DISTINCT COUNT book_id)
--------------
Calculated measures:
Amnt_Projects
iif ([Measures].[ Amount of projects ] = 0 OR [Measures].[ Amount of projects] = NULL,0,[Measures].[ Distinct amount of projects])
Amnt_Publications
(similar to the above one)
Amnt_E_books
(similar to the above one)
---------------------------
Dimensions:
dimPROFESSORS
- prof_id
-surname
-name
-gender
dimPROJECTS
- proj_id
-type name
-name
dimPUBLICATIONS
- pub_id
-type name
-name
dimE_BOOKS
- book_id
-name
Date_Projects
-date_id
-years
Date_Publications
-date_id
-years
Date_E_books
-date_id
-years


For example, when I browse the cube:
prof_id____Amount of projects___Distinct amount of projects___Amnt_Projects
1032------------------- 30 --------------------------1----------------1
1070-------------------90 --------------------------2----------------2
1111-------------------0 ---------------------------1----------------0
1137-------------------0 ---------------------------1----------------0
1234-------------------1404--------------------------9----------------9
1721-------------------504--------------------------7----------------7
2661-------------------85 --------------------------5----------------5
...--------------------...---------------------------...----------------...
6999------------------- 20---------------------------1-----------------1
9956-------------------50---------------------------5-----------------5
Unknown----------------(empty)---------------------(empty)-----------0
Grand Total------------ 2421------------------------11-----------------11


Grand Total 11 is the amount of distinct projects +1 (because of the unknown member). So the last column shows the right amount of projects for the professor but I want Grand Total to sum those values and show, how many projects do the professors have (it should be 59 if for all professors). How could I get the right value to be shown in Grand Total?

View 1 Replies View Related

Distinct Count With Null Values (grand Total)

May 10, 2007

Hello,

I am using SQL Server 2005. I have a DB of professors and information related with them. I created the cube, it consist of:
Measures:
Measure group Professors:
Amount of projects (COUNT proj_id)
Amount of publications (COUNT pub_id)
Amount of e_books (COUNT book_id)
--------------
Measure group Projects:
Distinct amount of projects (DISTINCT COUNT proj_id)
--------------
Measure group Publications:
Distinct amount of publications (DISTINCT COUNT pub_id)
--------------
Measure group E_books:
Distinct amount of e_books (DISTINCT COUNT book_id)
Calculated measures:
Amnt_Projects
iif ([Measures].[ Amount of projects ] = 0 OR [Measures].[ Amount of projects] = NULL,0,[Measures].[ Distinct amount of projects])
Amnt_Publications
(similar to the above one)
Amnt_E_books
(similar to the above one)
---------------------------
Dimensions:
dimPROFESSORS
- prof_id
-surname
-name
-gender
dimPROJECTS
- proj_id
-type name
-name
dimPUBLICATIONS
- pub_id
-type name
-name
dimE_BOOKS
- book_id
-name
Date_Projects
-date_id
-years
Date_Publications
-date_id
-years
Date_E_books
-date_id
-years


For example, when I browse the cube:
prof_id____Amount of projects___Distinct amount of projects___Amnt_Projects
1032------------------- 30 --------------------------1----------------1
1070-------------------90 --------------------------2----------------2
1111-------------------0 ---------------------------1----------------0
1137-------------------0 ---------------------------1----------------0
1234-------------------1404--------------------------9----------------9
1721-------------------504--------------------------7----------------7
2661-------------------85 --------------------------5----------------5
...--------------------...---------------------------...----------------...
6999------------------- 20---------------------------1-----------------1
9956-------------------50---------------------------5-----------------5
Unknown----------------(empty)---------------------(empty)-----------0
Grand Total------------ 2421------------------------11-----------------11


Grand Total 11 is the amount of distinct projects +1 (because of the unknown member). So the last column shows the right amount of projects for the professor but I want Grand Total to sum those values and show, how many projects do the professors have (it should be 59 if for all professors). How could I get the right value to be shown in Grand Total?

View 2 Replies View Related

Adding Grand Total To A Column Group In A Matrix. Please Help!

Sep 7, 2007

Hello Guys,
I am working on a matrix report which has several row groups and 1 column group. After execution, the column group wil end up with several columns containg numeric counts. I would like to have the grand total for each "column group" column as a last row on this report.
For row groups you can just right click "Subtotal", but that is not possible for column group. Could someone please help me to find a clever way of accomplishing this, please. Thank you so much for your help!

View 7 Replies View Related

Power Pivot :: Sum Of The Parts Not Equaling Grand Total?

Nov 18, 2015

I've created a measure counting instances of unique identifiers utilizing the following formula. However, the Grand Total does not equal the sum of the sub-totals. 

=CALCULATE(COUNTROWS(DISTINCT('Rawdata File'[Identifier])),ALL('Rawdata File'[Identifier]))

View 8 Replies View Related

Pb With Calculated Measure And Totals (grand Total Or Anysubtotals)

May 20, 2008



Hi,

I've created a calculated measure which is a division between 2 other measures which i also have displayed in the cube.
of course as soon as there is some level of aggregation, the shown result is an averaged division and therefore is wrong.


here is some example:
A 16874
B 956
C 1354
D 264
E 103
F 81
G 6
H 3
X 23
Total 5198.36...

here the wanted result would be a simple some of all the other values (=19664)

How could i treat totals/aggregation differently or have any good way of solving this issue?
I know there is the aggregatefunction propertie for normal dimension, but i'm not familiar with calculated measures and it seems properties that can be accessed through BIStudio's interface is rather limited.


thanks a lot in advance for your help. I've been looking for tweaks on the data to trick the cube, but couldn't find any way of getting the result i'm looking for.

View 1 Replies View Related

Err On Grand Total In Cube Measure Using A Distinct Count Agregation

May 28, 2007

Hi,

I'm using sql server analysis services 2000, i have a problem with grand total when i select more than one member of any demension. the measure of this cube is built on a distinct count agregation function. i have only one measure in th cube

can some body help me !!

View 1 Replies View Related

Reporting Services :: Report Builder 3.0 - Separate Grand Total Section To A New Page?

May 5, 2015

is it possible to separate Grand Total of a sub group to a new page?

I tried using advanced mode, find the first line the Grand Total section and set its "RepeatOnNewPage" to true, but, when I execute the report, it will throw an error something like the value of RepeatOnNewPage of the TablixMemeber must be the same as its previous object.

I need my report pages to separate by subGroup(SubGroupA, SubGroupB, A+BTotal).

View 2 Replies View Related

Analysis :: Show Grand Total When Using SSAS Tabular Role Security Permission

Oct 30, 2015

If user want to see the grand total for a measure with include all members, even though the user has limited access for that member, so how we can do using DAX?For example, let’s say the total revenue for all the divisions in a cube is $15,000. You create a role called “Division A”, and set it up so members of that role can only see the revenue for Division A, which totals $3,000. If you use a front-end tool like Excel to access the cube and use the division hierarchy to see the total revenue, you will see the revenue of $3000 for Division A, but also want to see the Grand Total for the revenue as $15,000How we can achieve above scenerio in tabular model (DAX).

View 3 Replies View Related

SQL Server 2012 :: Sales Over Years - Retrieve Values In Single Query For Multiple Years And Grand Total?

Apr 24, 2015

I need to list customers in a table that represents sales over the years.

I have tables:

Customers -> id | name |...
Orders -> id | idCustomer | date | ...
Products -> id | idOrder | unitprice | quantity | ...

I am using this SQL but it only gets one year:

SELECT customers.name , SUM(unitprice*qt) AS total
FROM Products
INNER JOIN Orders ON Orders.id = Products.idOrder
INNER JOIN Customers ON Customers.id = Orders.idCustomer
WHERE year(date)=2014
GROUP BY customers.name
ORDER BY 2 DESC

I need something like this:

customer | total sales 204 | total sales | 2015 | total sales (2014 + 2015)
--------
customer A | 1000$ | 2000$ | 3000$
customer B | 100$ | 100$ | 200$

Is it possible to retrieve these values in a single SQL query for multiple years and grand total?

View 6 Replies View Related

Reporting Services 2005 - Showing Wrong Version

Jun 15, 2006

Hi

I installed RS 2005, SP1 and then the rollup fix 2153 however; if I run http://server/reportserver or view the reportserver log file, it shows version 2047 which is the SP1 version. I have added the tail end of the rollup hotfix log file which shows I have installed it.

Is this a known issue?

06/14/2006 16:03:57.153 Failed to read version information for the following file: C:Program FilesMicrosoft SQL ServerMSSQL.1Reporting ServicesReportServerCatalog.sql
06/14/2006 16:03:57.169 Failed to read version information for the following file: C:Program FilesMicrosoft SQL ServerMSSQL.1Reporting ServicesReportServerStylesHtmlViewer.css
06/14/2006 16:03:58.216 Attempting to install file: sqlrun_rs.msp
06/14/2006 16:03:58.263 Attempting to install file: \NLDN9577DWWd$89a527f93aa2bb044103hotfixrsFilessqlrun_rs.msp
06/14/2006 16:03:58.278 Creating MSP install log file at: C:WINDOWSHotfixRS9LogsRS9_Hotfix_KB918222_sqlrun_rs.msp.log
06/14/2006 16:03:58.294 Successfully opened registry key: SoftwarePoliciesMicrosoftWindowsInstaller
06/14/2006 16:03:58.294 Failed to read registry key: Debug
06/14/2006 16:04:44.826 MSP returned 0: The action completed successfully.
06/14/2006 16:04:45.092 Successfully opened registry key: SoftwarePoliciesMicrosoftWindowsInstaller
06/14/2006 16:04:45.107 Failed to read registry key: Debug
06/14/2006 16:04:45.123 Successfully installed file: \NLDN9577DWWd$89a527f93aa2bb044103hotfixrsFilessqlrun_rs.msp
06/14/2006 16:04:45.139 Restarting RS Service ReportServer since it was previously running
06/14/2006 16:04:45.154 Attempting to start service: ReportServer
06/14/2006 16:04:51.936 Successfully started service: ReportServer
06/14/2006 16:04:51.983 Successfully installed target: NLDN9577DWW
06/14/2006 16:04:51.998 Successfully installed instance: MSSQLSERVER
06/14/2006 16:04:52.014 Successfully opened registry key: SoftwareMicrosoftWindowsCurrentVersionUninstall
06/14/2006 16:04:52.608
06/14/2006 16:04:52.623 Product Status Summary:
06/14/2006 16:04:52.639 Product: SQL Server Reporting Services 2005
06/14/2006 16:04:52.701 MSSQLSERVER - Success
06/14/2006 16:04:52.717
06/14/2006 16:06:05.500 Hotfix package closed



Cheers

Steve

View 1 Replies View Related

SQL 2012 :: Log Shipping - Secondary Database Path Showing Wrong Location?

Mar 17, 2014

I've configured log shipping to use for DR purposes. I'm concerned that the physical location of the secondary is mis-reported by SQL Server Management Studio.

Viewing the secondary location (with Studio DB_name Properties Files) shows the path of the primary DB (I expected it to show the path of the secondary).

This SQL command shows the correct/actual paths of both primary and secondary DB's when run on their host servers.

SELECT name, physical_name AS CurrentLocation, state_desc FROM sys.master_files

Is this just cosmetic?

Here is an Example of how the Studio shows the incorrect path for the secondary.

Example:

(Primary) servername=prodSrv, DBname=aquaDB, Actual_Path=G:aquaDB, SQL-studio-Properties-Path=G:AquaDB, sys.master_files Path=G:AquaDB,

Log shipped to

(Secondary / Read Only) servername=DRSrv, DBname=aquaDB, Actual Path=F:aquaDR, SQL-studio-Properties-Path=G:AquaDB(WRONG), sys.master_files Path=F:aquaDR

View 2 Replies View Related

ROLLUP - Retrieve A List Showing Total Repair Cost Per Year

Mar 1, 2014

I have a question regarding ROLLUP and how to use the operator.

I've been asked to retrieve a list showing the total repair cost per year displaying Transport Type, Manufacturer and Transport. The query I used is:

SELECT ty.Description AS TransportDescription,
t.SerialNumber AS Transport,
ty.Manufacturer,
SUM (r.RepairCost) AS RepairCost,
YEAR(r.EndWorkDate) AS [Year]

[Code] .....

How could I use the rollup function to display subtotals per Transport Type, Manufacturer and Transport?

View 1 Replies View Related

SQL Server 2008 :: Balance Sheet Query Showing Wrong Amounts On VAT Accounts Only

May 21, 2015

I have one query which is pulling Balance sheet amounts from SAP Business One database. The query is giving the correct figures for the rest of the accounts except for the VAT Input refundable account 123600 and VAT Output Payable account 221400. The query sums up totals at Title account level(FatherNum) and the above accounts are the title accounts:

SELECT CAST(T0.TransId AS Varchar(30)) AS TransId, CASE WHEN t3.FatherNum IN ('100000', '350000') THEN '-3 OK' ELSE CAST(T0.TransType AS Varchar(30))
END AS TransType, CAST(T0.BaseRef AS VarChar(30)) AS BaseRef, T0.RefDate,T0.Number as Docnum, DATEPART(Month, T0.RefDate) AS JrnMonth, T0.FinncPriod, T1.Account, T1.Debit,
T1.Credit, T1.Debit - T1.Credit AS JrnAmt, ISNULL(T1.SYSCred, 0) AS SysCred, ISNULL(T1.SYSDeb, 0) AS SysDeb, T1.ShortName, T1.Ref1, T1.Ref2,

[code]....

View 8 Replies View Related

Reporting Services :: Wrong Total Values Are Coming With SUM Function

Sep 7, 2015

Create report with SharePoint list. Columns are displaying on the report I used out of the group SUM function and it is group by report. one group total is showing correct total and other groups are showing wrong total and showing too much big value even there is whole column is empty.where value is not in column I am using "-" with IIF function. these columns are calculating by using date difference function between two date columns. these values coming with minus value . so ABS function is also using.

Columns calculation expression:

=IIF(ISNOTHING(Fields!DateCAPackage.Value)
OR (ISNOTHING(Fields!Date_CA_Application.Value)) ,
"-" , CINT(Abs(DateDiff("d",Fields!Date_CA_Application.Value,Fields!DateCAPackage.Value))))

Total calculation expression:

=Sum(ABS(DateDiff(
"d",Fields!Date_CA_Application.Value,Fields!DateCAPackage.Value)))

View 5 Replies View Related

Wrong Result Set

Apr 16, 2006

Hello all,I have the following t-sql batch:create procedure stp_test(@p_date1 as datetime = null,@p_date2 as datetime = null)as beginset @p_date1 = isnull(@p_date1, <some expression>)set @p_date2 = isnull(@p_date2, <some other expression>)select<a lot of columns>from<some table>inner join <some other table> on <expression>inner join <dirived table> on <expression>wheredate1 <= @p_date1 anddate2 <= @p_date2 and(date1 >= @p_date1 ordate2 >= @p_date2)endgoexec stp_testThis gives a WRONG resultset.When I replace the variables with hardcoded values in the right format, thereturned result set is CORRECT, as followswheredate1 <= 'hard coded date value 1' anddate2 <= 'hard coded date value 2' and(date1 >= 'hard coded date value 1' ordate2 >= 'hard coded date value 2')When I elimate the derived table with a temporary table, the returned resultset is CORRECTWhen I store the parameters in a local variable, and use the local variable,the returned result set is CORRECT, as followscreate procedure stp_test(@p_date1 as datetime = null,@p_date2 as datetime = null)as begindeclare @l_date1 datetimedeclare @l_date2 datetimeset @l_date1 = @p_date1set @l_date2 = @p_date2set @l_date1 = isnull(@l_date1, <some expression>)set @l_date2 = isnull(@l_date2, <some other expression>)select<a lot of columns>from<some table>inner join <some other table> on <expression>inner join <dirived table> on <expression>wheredate1 <= @l_date1 anddate2 <= @l_date2 and(date1 >= @l_date1 ordate2 >= @l_date2)endgoWhen I put less columns in the select list, the returned result set isCORRECT, it doesnt make sense wich columns I remove from the select list.The tables are not small (500.000 rows) and also is the result set. I usethis construction elsewhere, on other table combinations, but dont haveproblems. So the content of the data makes difference.Seems to me as a bug.My question is: Can I say the derived table is instable in SQL server andcauses the problem of the wrong result set here?Peter

View 3 Replies View Related

Change Display Of Result Set From Showing As Rows To Column As One Or More

May 13, 2014

I am interested in changing the way that data is displayed in my result set.Essentially I want to display a selection of rows (1 to n) as columns, the following diagram explains my intentions.Perhaps one of the greatest challenges here is the fact that I do not have a concrete number of rows (or BIN numbers). Each stock item could be stored in one or more BINS, which I will not know until running my query.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved