Viewing 15 posts - 256 through 270 (of 284 total)
Though not as cool a solution as Mr. Lange's tally table, this alternative is more math oriented than set oriented and is very fast. Plus you could easily turn this...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 13, 2013 at 3:08 pm
CTE's can really make this kind of query so easy!
Try this out:
;with dups as
(
Select tesplan_id, tc_external_id, tcversions_id, execution_ts,
...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 4, 2013 at 8:43 am
Luis Cazares (9/2/2013)
I reviewed the results ans checked the need for a null validation, however it's not needed on all columns and date zero is possible.
You are right. I was...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 2, 2013 at 10:55 am
vignesh.ms (9/2/2013)
is there any other way ?
This way is fine. It just needs to be modified slightly to handle nulls.
[Code]
Select a, b, c,
case when isNull(a,...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 2, 2013 at 9:15 am
I see what you are after. The bottom line is that you could do the sub-totaling you are looking for, but it is not elegant or pretty. This is what...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 21, 2013 at 11:50 am
As you have found out, SQL is not at its best presenting data to the world. That is usually the job of the front end!
I was not 100% sure what...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 20, 2013 at 12:37 pm
ChrisM@Work (8/20/2013)
This works and the explanation fits too, but why LEFT JOIN to the link table? dpd shouldn't contain any doctors which aren't in the doctors table, or drugs which...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 20, 2013 at 3:23 am
I think this is what you are after:
select d.name, d.packsize, doc.doctorname, doc.location
from Doctor_Prescribed_Drugs dpd
left join Doctor doc on dpd.doctorref = doc.doctorref
left join Drugs ...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 18, 2013 at 7:32 am
Why did you send them via PM? Now nobody else gets a chance to answer your question. More eyeballs means better odds at getting more and possible better answers.
JAT
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 17, 2013 at 1:09 pm
LinksUp
You said
The Where clause you have specified will NOT return any row that has a date of 01/03/2000 if the time portion is anything other than 0's. I've...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 15, 2013 at 1:23 pm
Lynn Pettis (8/13/2013)I want records for datetimes between 01/01/2000 (after midnight) through 01/03/2000 (through midnight).
WHERE orderdate BETWEEN '01/01/2000 00:00:00:000 AND '01/03/2000 00:00:00.000'
After re-reading the requirements, I can see...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 13, 2013 at 11:43 am
Sean Lange (8/13/2013)
Or you can cast your datetime column as date.
WHERE cast(orderdate as date) BETWEEN '01/01/2000' AND '01/03/2000'
Would work well for any query that returned somewhere around less than 10K...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 13, 2013 at 10:18 am
Oracle765 (8/11/2013)
The table is created dynmaically so it will not always be the same columns in the first 3.
If the table is created dynamically, can't you use a case statement,...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 12, 2013 at 6:28 pm
Oracle765 (8/11/2013)
I am stuck on a way around a query and wonder if it is possible.
I want to always select the first 3 [columns] rows in the exact order...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 12, 2013 at 4:53 pm
polkadot (8/12/2013)
WHERE orderdate BETWEEN '01/01/2000 00:00:00:000 AND '01/03/2000...
__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 12, 2013 at 3:04 pm
Viewing 15 posts - 256 through 270 (of 284 total)