Advanced Minds

  • Decrease font size
  • Default font size
  • Increase font size
  • default color
  • red color
  • green color
FireBoard
Welcome, Guest
Please Login or Register.    Lost Password?
union c Can someone help me with a UNION error (1 viewing) (1) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: union c Can someone help me with a UNION error
#8588
Allen May (Visitor)
Click here to see the profile of this user
Birthdate:
union c Can someone help me with a UNION error  
I have been up and down my SQL and can't find WHY I keep getting an error on my UNION keyword. When I run the below SQL through Query Analyzer, it comes back with: Server: Msg 156, Level 15, State 1, Line 5 Incorrect syntax near the keyword 'UNION'. Server: Msg 156, Level 15, State 1, Line 8 Incorrect syntax near the keyword 'WHERE'. Server: Msg 156, Level 15, State 1, Line 14 Incorrect syntax near the keyword 'WHERE'. Any help would be appreciated. Thanks -Allen May This e-mail address is being protected from spam bots, you need JavaScript enabled to view it SELECT b.addition + ' ' + ISNULL(z.desc_, b.desadd) strucode, CASE b.yearblt WHEN '0' THEN ' ' ELSE STR(b.yearblt,4,0) END yearblt, CASE SUM(b.yearblt) WHEN '0' THEN ' ' ELSE STR(SUM(b.sqft))+' '+'Square Feet' END sqft, 'Addition' rec_type FROM aditions b LEFT OUTER JOIN codedesc z ON (z.GROUP_ = 'ADITIONS' AND z.code = b.addition) WHERE (b.parcelid='6010001007000' AND b.cardnum= '01') AND (b.deleted!='T' AND b.deleted!='1' OR b.deleted IS NULL)GROUP BY b.fig_id ORDER BY rec_type, strucode UNION ALL SELECT d.buildtype + ' ' + ISNULL (x.desc_, d.desout) strucode, RTRIM(d.condition) condcode, ISNULL(w.desc_,' ') conddesc, CASE d.yearblt WHERE '0' THEN ' ' ELSE STR(d.yearblt,4,0) END yearblt, CASE SUM(d.sqft) WHERE '0' THEN ' ' ELSE STR(SUM(d.sqft))+' '+'Square Feet' END sqft, 'Outbuilding' rec_type FROM outbldg d LEFT OUTER JOIN codedesc x ON (x.GROUP_ = 'OUTBLDG' AND x.code = d.buildtype) LEFT OUTER JOIN codedesc w ON (w.group_ = 'CONDITION' AND w.code = d.condition) WHERE (d.parcelid='6010001007000' AND d.cardnum='01') AND (d.deleted!='T' AND d.deleted!='1' OR d.deleted IS NULL)GROUP BY d.fig_id UNION ALL SELECT c.featrule+' '+ISNULL(c.desc_,' ') strucode, ' ' condcode, ' ' conddesc, ' ' yearblt, CASE SUM(c.units) WHERE '0' THEN ' ' ELSE STR(SUM(c.units))+' '+c.unit_type END sqft, '' rec_type FROM feature c WHERE (c.parcelid='6010001007000' AND c.cardnum= '01') AND (c.deleted!='T' AND c.deleted!='1' OR c.deleted IS NULL)GROUP BY c.featrule
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#8589
BP Margolin (Visitor)
Click here to see the profile of this user
Birthdate:
union c Can someone help me with a UNION error  
Allen, SQL (the language) and SQL Server do not support placing ORDER BY clauses in the individual SELECTs of a UNION. There can be only a single ORDER BY clause at the end of the entire SELECT. That single ORDER BY applies to the result set produced by the UNION.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
905 brak autoryzacji sprawdz autoryzacje nieautoryzowano wymiana linkow
dell coupon organizedwisdom com did they find hitler tech news news channel 8