Jul
31
revised occupancy reports for hospitals
added 1226 characters in body
Jul
31
answered occupancy reports for hospitals
Jul
31
answered sql - Query to return duplicate rows with some differing entries
Jul
30
comment Insert into Select does not insert the same data order correctly
someone asking this question:stackoverflow.com/questions/14424929/… "Preserving ORDER BY in SELECT INTO"
Jul
30
answered Add a default value in group by select in case a specific value is not present
Jul
30
answered SQL: Get the first value of a GroupBY Clause
Jul
29
comment Select every date where date is equal to today's date minus 1 day - Not working with dateadd on Month/year - T SQL
Just to clarify- leaving the column being filtered by untouched allows it to make use of the index, but are you saying that the are special optimizations for casting of datetime to date? (assuming as it must be used a lot)
Jul
29
answered Select every date where date is equal to today's date minus 1 day - Not working with dateadd on Month/year - T SQL
Jul
29
comment SQL Read Table Between dates, if nothing exists still write as empty
it is a new table that you add to the database. which database engine are you using? normally your alternatives to adding a table like this are using a cursor or doing this outside of the DB. maybe there is some new methods in later db engines that give other options.
Jul
29
comment PARTITION BY Name, Id to compare and detect problems
You are very welcome, i hope it helps. you have a working SQL fiddle that pretty clearly specifies everything. questions here are meant to be specific rather than ongoing support with a task.
Jul
29
comment SQL Read Table Between dates, if nothing exists still write as empty
You need to create the date table, its like a number table: dba.stackexchange.com/questions/11506/… if you give some example data in tables (preferreably in SQLFiddle: sqlfiddle.com) with expected output it will save a lot of time.
Jul
29
comment PARTITION BY Name, Id to compare and detect problems
This is because its not null its an empty string, you just have to code for that too. I have updated the answer but please mark this question answered and ask a new question is you are having subsequent issues like this.
Jul
29
revised PARTITION BY Name, Id to compare and detect problems
added 2358 characters in body
Jul
29
comment PARTITION BY Name, Id to compare and detect problems
Yes that was a typo sorry i have corrected it see SQLFiddle for running example though.. as for your second update i don't know what you mean, there is a user 'john' in the SQLFiddle that seems to do exactly what you are saying and works fine
Jul
29
revised PARTITION BY Name, Id to compare and detect problems
deleted 31 characters in body
Jul
29
revised SQL Read Table Between dates, if nothing exists still write as empty
added 1505 characters in body
Jul
29
answered SQL Read Table Between dates, if nothing exists still write as empty
Jul
29
comment PARTITION BY Name, Id to compare and detect problems
Updated the answer, these types of extra requirements are why i lean towards temp tables in these types of problems but i have given a solution using a union which is also a fairly clean way to do it
Jul
29
revised PARTITION BY Name, Id to compare and detect problems
added 2473 characters in body
Jul
28
comment MSSQL Create dynamically queries to select all related data in DB based on entry table and ID
there is much you would need to add to make it robust - e.g. it would be better if it worked when the id column was not the same column used in the foreign key. also this will do nothing for many to many relationships etc. that are not directly referencing the specific table, for that you would need to do something quite a bit fancier that recursed through the linked tables.
1 2 3 4 5