Calgarypuck Forums - The Unofficial Calgary Flames Fan Community

Go Back   Calgarypuck Forums - The Unofficial Calgary Flames Fan Community > Main Forums > The Off Topic Forum > Tech Talk
Register Forum Rules FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread
Old 04-10-2011, 06:04 AM   #21
Devils'Advocate
#1 Goaltender
 
Devils'Advocate's Avatar
 
Join Date: Jul 2005
Exp:
Default

First, you have a ; after pp.price_plan.

Second, that's one funky "GROUP BY". I've never seen any syntax like that before in my life.
Devils'Advocate is offline   Reply With Quote
The Following User Says Thank You to Devils'Advocate For This Useful Post:
Old 04-10-2011, 08:04 AM   #22
Jedi Ninja
Scoring Winger
 
Jedi Ninja's Avatar
 
Join Date: Mar 2009
Exp:
Default

In addition to the semi colon issue you just mentioned, I don' think you need Price in your subquery's GROUP BY.

I generally prefer to break down the query into Views in situations like this, as joining to nested queries like that is ugly and difficult to read.

FYI, you can also do a nested query in the SELECT portion of the clause, e.g.:
Quote:

SELECT
gr.g_name,

Lodging_Cost = (DATEDIFF(d, r.res_checkout_date, r.res_checkin_date) * pp.rate ) + ISNULL(i.inv_amount, 0) ,

Total_Dining =
( SELECT SUM(price)
FROM dining_order do
JOIN dining_menu dm ON do.item = dm.item
WHERE do.r_confirmation_no = gr.r_confirmation_no)

FROM guest_reservation gr
LEFT OUTER JOIN invoice i ON gr.confirm_no = i.confirm_no
JOIN reservation r ON gr.confirm_no = r.confirmation_no
JOIN price_plan pp ON r.price_plan = pp.price_plan;

Last edited by Jedi Ninja; 04-10-2011 at 08:07 AM.
Jedi Ninja is offline   Reply With Quote
The Following User Says Thank You to Jedi Ninja For This Useful Post:
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 11:41 PM.

Calgary Flames
2023-24




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Calgarypuck 2021