Yorkshire Divers

Deep Blue Technical
Go Back   YD Scuba Diving Forums > Non-Diving Related Forums > Technology
User Name
Password

Welcome to the YD Scuba forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Technology: Discuss MORE SQL Help in the Non-Diving Related Forums forums: Anyone? Sorry - but have tried endless options to get this to work for the cases where the selection fields are ...

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 07-04-08, 02:46 PM
MartinS's Avatar
MartinS MartinS is offline
Senior Member
 

Join Date: Jul 2002
Location: Redhill, Surrey
Posts: 1,538
MartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the sea
Red face

Anyone?
Sorry - but have tried endless options to get this to work for the cases where the selection fields are from the financial table, but nothing works.
Martin
__________________
Never test the depth of the water with both feet!
69 Divers SAC
Yorkshire Divers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 07-04-08, 04:44 PM
uwila's Avatar
uwila uwila is offline
Do nothing at ground level
 

Join Date: Apr 2006
Location: New Malden, Surrey
Posts: 1,636
uwila communes with fishuwila communes with fishuwila communes with fishuwila communes with fishuwila communes with fishuwila communes with fishuwila communes with fishuwila communes with fishuwila communes with fishuwila communes with fishuwila communes with fish
form an email I sent earlier...

Martin,

firstly, are you now saying that the user should only be able to see the results where InputStage=2 and the InputStage=1 records should be ignored entirely?

If so, please let me know as the query should be changed radically. Anyhow, to answer your last question directly:




As you wish to use a number of columns from the temporary table, you should include them in the 'inner' query.


SELECT COUNT(DISTINCT CAST(V.ValuationID AS varchar(10))
+ CAST(F.InputStage AS varchar(10)))
FROM Valuations V
INNER JOIN (SELECT ValuationID, MAX(InputStage) AS InputStage, PriceInflation, NomDiscRateAccruedPenWid, DiscountRateType
FROM Financial
GROUP BY ValuationID, PriceInflation, NomDiscRateAccruedPenWid, DiscountRateType) AS F ON F.ValuationID = V.ValuationID
INNER JOIN ValuationResults VR ON VR.ValuationID = V.ValuationID AND F.InputStage = VR.InputStage
INNER JOIN LUAssetAllocation AA ON AA.ValuationID = V.ValuationID
AND (F.NomDiscRateAccruedPenWid IS NOT NULL) AND (F.PriceInflation IS NOT NULL)
AND AA.AssetCategoryID IN (1, 2, 3, 4, 5, 6)
AND F.DiscountRateType = 0



As a matter of style (and ease of maintenance by another person, and as a means of getting the query correct!!!), I consider it bad form to use the same alias (in this case 'F') in 2 different scopes. In your reply to me, you used F as an alias within the temporary table generation and as the alias for the temporary table. The 2 uses of F are totally independant and the inner one does not have scope outside of the query in which it appears. It is easy to confuse the 2 - which is what you did when you wondered why the columns from F were unknown.
__________________
88Kg: 2 down, 8 to go
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 08-04-08, 08:38 AM
MartinS's Avatar
MartinS MartinS is offline
Senior Member
 

Join Date: Jul 2002
Location: Redhill, Surrey
Posts: 1,538
MartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the sea
Chris
I have replied to your email directly - thanks.
Martin
__________________
Never test the depth of the water with both feet!
69 Divers SAC
Yorkshire Divers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Sponsored Links

Yorkshire Divers - RSS Feed
All times are GMT +1. The time now is 10:58 PM.
Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0 RC6
Trademark and all rights reserved : © YD.com Ltd (2006)
YD.com Ltd (Registered in England - 05886696)
Other sites : Golf Clubs | New Premiership Football Kits | MP3 Portable Players | MP3 Players For Sale | Replica Football Kits

Forums Directory