|
Dude you are a Genius. I modified the script a but and it worked like a baby. Thnks dude.. I owe u a beer.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[sp_MS_IssuesReport_Num2](@PeriodName varchar(50), @BeginningDate datetime, @EndDate datetime)AS
BEGIN
SELECT dbo.RPT_GetPeriod(@PeriodName, A.PeriodDate) AS Period,
SUM(A.IssueReceived) AS IssuesReceived,
SUM(A.IssueClosed) AS IssuesClosed
FROM(
SELECT CreateDate AS PeriodDate,
1 AS IssueReceived,
0 AS IssueClosed
FROM Ms_threads
WHERE CreateDate BETWEEN @BeginningDate and @EndDate
UNION ALL
SELECT StatusDate AS PeriodDate,
0 AS IssueReceived,
dbo.RPT_IsInquiryCompleted(CurrentStatusID) AS IssueClosed
FROM Ms_threads
WHERE StatusDate BETWEEN @BeginningDate and @EndDate
) A
GROUP BY dbo.RPT_GetPeriod(@PeriodName, A.PeriodDate) -- Added the date floor function.
ORDER BY dbo.RPT_GetPeriod(@PeriodName, A.PeriodDate)
end
Thank Code Project....This deserves a 10 not a 5...hehehehe!!
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|
|
Hi there.
I'm having some trouble trying to do the following:
I have some data in my DB:
ID (PK)
type
creation_date
What I want to do is to get the top x results by month/year of creation_date.
I already have a query to count the number of ID's in some month/year, grouped by type, with a 'group by'. This would return the number of ID's with type T in month mm of year yy, for all months and years that appear on creation_date.
Now I need to return the top X results in month 01/2007, top X results in month 02/2007 and so on.
I already make this happen, with a stored procedure, but I'm using another stored procedure to get all the data to a XML file, and I'm not being able to call the stored procedure with the top from the stored procedure that will generate the XML...
Any ideia, anyone?
Joao
|
|
|
|
|
use union
example:
SELECT * FROM Table1<br />
UNION<br />
SELECT * FROM Table2
I Love SQL
|
|
|
|
|
|
|
How does this solve the problem? Did you even read his post?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Well, that will not solve my problem, because I do not know exactly how many months/years there could be in the first place.
I do have something like this:
select count(ID), type, year(creation_date), month(creation_date)
from table1
group by year(creation_date), month(creation_date), type
which returns the count per type/month/year... After that I just want to show top 5 types per month/year...
As I said, I could do something like what I want with a stored procedure, with a loop foreach month/year, but I do not know how to run a stored procedure from inside another stored procedure...
I've tried 'exec sp_getdata' from inside the other stored procedure, but that didn't work...
Joao
|
|
|
|
|
A non-clever method is to use temp table instead of a single sql script. :p
|
|
|
|
|
|
by using sql server agent we backup the database as we required.in the same way can i send an email.
what my requirement is , to send mails to relevent parties when the complaints are not handled within 24 hrs , they are lodged.
to send the email i should specify the mail server,but what if i'm not having a mail server and using a free mail server in the internet,how to configure the database mail..
-- modified at 0:15 Wednesday 12th September, 2007
|
|
|
|
|
if you are using 2005 then it has built in email.
If you are using SQL2000 install CDONTS and look for articles on google on how to use it,
|
|
|
|
|
I want to filter my data while im typing the word that i want to search on a textbox.tnx
Sunshine
|
|
|
|
|
Where is your data coming from ? It seems pretty straightforward to me, if you're using a database and want to filter from the DB. Just build a query on each keypress to return the data valid for that search.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
yes im using a database and the search result would appear to the gridview...im having a combobox that would give the textbox choices on which to filter...but i dont know how to use the like clause in the select statement propely..
sql = "Select Supplier_Information.Supplier_ID,Supplier_Information.Supplier_Name,Supplier_Information.Address,Supplier_Information.Contact_No, Products.Product_ID, Products.Product_Name,Products.Product_Type, Products.Present_Price, Products.Past_Price from Supplier_Information, Products where Supplier_Information.Supplier_ID like '%s-%' "
i have this code but it does not work properly...i want to come up with a textbox that would filter in every letter that they will type in the textbox.tnx
|
|
|
|
|
Whoah - this is a really bad design. Don't attempt to do this because you are going to be hitting the database after every keypress. The more users you have, the more you are going to hit the database. How would you handle the case where the user enters some text and then starts to delete text? Thats the same data being queried many times.
Please - rethink your design.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
any suggestive design that i could make?may i know exacly what is the bad design that you are pertaining of...tnx
|
|
|
|
|
I'm sorry, but I thought I'd made myself clear enough. Don't design a system where you are hitting the database so many times. Apart from anything else, you probably won't be able to retrieve the data and display it quickly enough if the user is a quick typist.
As for the design - identify a more natural point for retrieving the data.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
should i delete my combobox?or can i search any data on my database in my textbox without giving any choices for filtering
|
|
|
|
|
This has stopped being a question about databases and become a question about an autofiltering combo box. The exact details of how to do this depends on whether you are using Win Forms or ASP.NET.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
i using vb.net...actually i really want to know about filtering...hos to use the like clause for searching
|
|
|
|
|
shyne7 wrote: i using vb.net
VB.NET is a language. The question was about frameworks. Which framework are you using? The ASP.NET framework or the WinForms framework (both of which are part of the larger .NET Framework)
shyne7 wrote: hos to use the like clause for searching
WHERE SomeColumn LIKE '%'+@SomeSearchTerm+'%'
@SomeSearchTerm is passes as a parameter for security
|
|
|
|
|
u want to filter
so ,
u are writing the query. ok then in where clause
fieldname like '" & textbox1.text & "%'
u will get the result
|
|
|
|
|
tnx...that helps...but i have two tables in one gridview...how could i view those in my gridview when i search for a data that is only in one of the tables
|
|
|
|
|
rohitsrivastava wrote: fieldname like '" & textbox1.text & "%'
NO NO NO NO!!!! Do NOT inject into SQL strings like this. I've been banging on about this for THREE years now! Doesn't anyone know about SQL Injection Attacks?!
SQL Injection Attacks and Tips on How to Prevent Them[^]
|
|
|
|
|
Ah well - at least I did mention parameterized queries (albeit in another post) . Don't worry Colin - some of the more professional members of the site have read/taken in your message. Perhaps your technical test should include a query that's wide open for Sql Injection and then ask candidates if they can tell you what's wrong with it.
Deja View - the feeling that you've seen this post before.
|
|
|
|