Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
khovorka
Starting Member
8 Posts |
Posted - 2014-03-19 : 12:23:47
|
Hello,I have not worked with Unions before and so this is my first attempt and I am getting an error near the UNION line. Any Help is appreciated:SELECT patientid, SUM(CAST(tot_steps AS int)) AS totstepsFROM workoutsWHERE patientid IN (12345) AND updated >= '2014-04-11' AND CAST(tot_steps AS int) > 0GROUP BY patientidORDER BY totsteps DESCUNION ALLSELECT patientid, SUM(CAST(steps AS int)) AS totstepsFROM exercises_weeklyWHERE patientid IN (12345) AND timestamp >= '2014-04-11' AND CAST(steps AS int) > 0GROUP BY patientidORDER BY totsteps DESCKim H. |
|
VeeranjaneyuluAnnapureddy
Posting Yak Master
169 Posts |
Posted - 2014-03-20 : 00:33:26
|
SELECT patientid, SUM(CAST(tot_steps AS int)) AS totstepsFROM workoutsWHERE patientid IN (12345) AND updated >= '2014-04-11' AND CAST(tot_steps AS int) > 0GROUP BY patientid--ORDER BY totsteps DESCUNION ALLSELECT patientid, SUM(CAST(steps AS int)) AS totstepsFROM exercises_weeklyWHERE patientid IN (12345) AND timestamp >= '2014-04-11' AND CAST(steps AS int) > 0GROUP BY patientidORDER BY totsteps,patientid DESCVeera |
|
|
|
|
|