Search Results

Showing results 1 to 15 of 15
Search took 0.01 seconds.
Search: Posts Made By: cgyrob ; Forum: MS SQL and child forums
Forum: MS SQL 25 Days Ago
Replies: 11
Views: 821
Posted By cgyrob
Why are you creating constants when you can just use the date functions in the where clause?



SELECT sum(Salesamount)
FROM Table
WHERE salesdate BETWEEN ...
Forum: MS SQL 26 Days Ago
Replies: 11
Views: 821
Posted By cgyrob
Just replace where I had @userInput with getdate() function


SELECT sum(Salesamount)FROM TableWHERE YEAR(salesdate) = YEAR(getdate())


You can do the same with the date functions example.
Forum: MS SQL 26 Days Ago
Replies: 11
Views: 821
Posted By cgyrob
There are alot of ways to do this here are a couple examples.

Using Year() function

Select sum(Salesamount)
From Table
where Year(salesdate) = Year(@userInput)
Forum: MS SQL Oct 19th, 2009
Replies: 2
Views: 516
Posted By cgyrob
You can't use the alias in the boolean test plus you should use a having clause to test the count(*) and not the where clause.


Select title, count(*) As Cnt
From poss_titles
Group By title...
Forum: MS SQL Sep 29th, 2009
Replies: 3
Views: 474
Posted By cgyrob
I beleive you need to use a full outer join with a coelesce on the 3 keys to get your desired result.


SELECT coalesce(a.Recordingid,b.recordingid), coalesce(a.Connection,b.Connection),...
Forum: MS SQL Aug 29th, 2009
Replies: 2
Views: 478
Posted By cgyrob
Did you try using wild cards.


Select * from Table1
Where Name LIKE ('%' + @Name + '%')
Forum: MS SQL Aug 5th, 2009
Replies: 4
Views: 380
Posted By cgyrob
Have you tried joining the subquery in the from clause instead of using the inline view.
Forum: MS SQL Aug 5th, 2009
Replies: 4
Views: 380
Posted By cgyrob
You should use code blocks as it makes it alot easier to read.



[/code}

Did you try an inline view? something like this maybe

[code=sql]
select
Forum: MS SQL Jul 21st, 2009
Replies: 7
Solved: Query question
Views: 332
Posted By cgyrob
I actually remember reading both of these threads and had commented on one of them but I still did not correlate them.
Forum: MS SQL Jul 21st, 2009
Replies: 7
Solved: Query question
Views: 332
Posted By cgyrob
@sknake - thanks, I didn't realize there were multiple threads relating to this db.
Forum: MS SQL Jul 21st, 2009
Replies: 7
Solved: Query question
Views: 332
Posted By cgyrob
I don't see where you are getting the alias 'c'

Besides that i think you are making it more difficult then it has to be.



select *
from dbo.tblLevelOneApprover a,...
Forum: MS SQL Jul 13th, 2009
Replies: 11
Views: 502
Posted By cgyrob
Link82

Group by does exactly that; groups your result set by the fields provided, in the example provided by sknake.


GROUP BY tblManagers.managerID, tblManagers.managerLastName,...
Forum: MS SQL Jul 8th, 2009
Replies: 7
Views: 570
Posted By cgyrob
I can't see any easy way to parse this string in a single select statement. I would try each individual piece at a time and then once you can parse each piece put them back together.

You might...
Forum: MS SQL Jul 8th, 2009
Replies: 7
Views: 570
Posted By cgyrob
You should be able to create a stored procedure and try to break off a piece at a time.

If you don't need the data live maybe you can make a dts package to run daily to parse these strings and...
Forum: MS SQL Jul 8th, 2009
Replies: 7
Views: 570
Posted By cgyrob
I have question.

How were these records imported into the table in the first place?

It would have been easier to parse them correctly when they were initially loaded.
Showing results 1 to 15 of 15

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC