Query To Show Only Users Who Logged On In Past 6 M

Feb 20, 2006

Hi All

I have built this query :

Select position, SubsidiaryName
from position
Where SubsidiaryName in ('country1','country2')
and position not like('testuser_%')
and position not like ('Inactive_%')
and position not like('olduser_%');

However when I run it, the result more accounts in country 1 than expected. I think it could be inactive users who have not logged into this system for 6 months or more. How can I build a query that incorporates my original query + shows only users who logged into the past 6 months ?

View 2 Replies


ADVERTISEMENT

How To Show Result For Each Day Of The Past 30 Days?

Feb 27, 2007

Hello,I would like to show the result  fo each day of the past 30 days. I might not have data to display for everyday but I still want the date to show up01/27/2007      resultA01/28/2007      resultB01/29/2007      .....02/26/2007      resultC02/27/2007      resultD
 Thanks for your helpArnold

View 3 Replies View Related

Users Logged In

Sep 28, 2007

Is there a way in 2005 to tell what user is logged into what databaseon the SQL Server?thanks,Scott

View 3 Replies View Related

SQL Users Logged In Report

Feb 15, 2006

Hi

I need to get a report that tells me the no. of users logged on to the SQL Server (this has to be an hourly report)

Will this do



WHILE 1=1
BEGIN
Select Hostname,getdate() from sysprocesses
WAITFOR DELAY '00:59:00'
END
GO


Will it have any bad affects on the SQL Server


Or can someone plz let me knw how to get that


Thanks

View 3 Replies View Related

How To Check How Many Users Logged In

Dec 15, 2007

Hi,
I have a question regarding sqlserver 2005
I am working on a production server.
how to check how many users are logged in currently in sqlserver and
also how to check the session info and memory usage by a paticular user......

View 1 Replies View Related

How To Show Only Records That Belong To The Logged In User.

Sep 28, 2007

Hello.I realize that this question has been asked before, but I still can't get it to work. Below are some links that might be of help:http://forums.asp.net/p/1159666/1913519.aspx#1913519http://forums.asp.net/p/1161930/1924264.aspxhttp://forums.asp.net/p/1116601/1732359.aspx#1732359http://forums.asp.net/t/1104718.aspxhttp://forums.asp.net/p/1096290/1655706.aspx#1655706http://forums.asp.net/p/1110162/1707952.aspx#1707952 Basically, I need a DropDownList to display only projects for which the logged in user is assigned as leader. The [Projects] table contains an integer ProjectId, a string ProjectName, a uniqueidentifier ProjectLeader, and other fields. Can someone help me with the SQL query and code?  * Here is the definition of the SqlDataSource: <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDB.MDFConnectionString %>" SelectCommand="SELECT [ProjectId], [ProjectName] FROM [Projects] WHERE ([ProjectLeader] = @Leader)" OnSelecting="SqlDataSource5_Selecting"> <SelectParameters> <asp:Parameter Name="Leader" Type="Object" /> </SelectParameters> </asp:SqlDataSource>  * Here is the definition of the SqlDataSource5_Selecting method:   protected void SqlDataSource5_Selecting(object sender, SqlDataSourceSelectingEventArgs e) { e.Command.Parameters("@Leader").Value = loggedInUserId; } where loggedInUserId is a global variable of type System.Guid. It has been evaluated in the Page_Load event to as: loggedInUserId = (System.Guid)Membership.GetUser().ProviderUserKey; Now the first problem I encounter is that when I run the page, the compiler complains and says, "error CS0118: 'System.Data.Common.DbCommand.Parameters' is a 'property' but is used like a 'method'." The second problem is when I insert the line: SqlDataSource5.SelectParameters("Leader").DefaultValue = loggedInUserId; in page_Load. The compiler again says, "error CS0118: 'System.Data.Common.DbCommand.Parameters' is a 'property' but is used like a 'method'." I've spent a long time trying to figure it out, but could not solve it. I would appreciate it if someone can help me out. Thank you very much. 

View 11 Replies View Related

How Can I Retrieving Records By Past One Week,past Month, Past Quarter Of Year And Then Half Year.

Apr 30, 2007

Hi every one,
I have a database table and currently users may retrieve records for a specified date range by providing the start and end dates and then records between those dates provided are retrieved. For example if users wanted to view all records entered in april, they would have to select 04/01/2007 as the start date and then 04/30/2007 as the end date. The records for april would then be displayed in a gridview.
How can configure my sql query such that instead the user selectes a month from a dropdownlist of 12 months. I would love a user to just select the desired month from a list instead of selecting start and end dates. Eg if they are intrested in a report for june, then they should just select june from the list instead of specifying the start and stop dates. HOW can i achieve this.

View 4 Replies View Related

Finding Users Logged In To A Session

Jan 6, 2005

I have a program which will show you users logged into a session. It's designed in MS Access and will also record citrix/terminal users. If you would like a copy of the program, download the attachment or email me at paulk@weccusa.org.

Paul Kohn
Database Administrator

View 12 Replies View Related

Getting Number Of Logged On Users To Server

Jul 20, 2005

SQL Server 2000 - MSDE 2000Is there a way to get the number of current users logged into a SQL 2000 Server (also MSDE)? Cant be distinct users as most users are logged into the database using the same login.-- Tim Morrison--------------------------------------------------------------------------------Vehicle Web Studio - The easiest way to create and maintain your vehicle related website.http://www.vehiclewebstudio.com

View 4 Replies View Related

Maximum Users Logged In Sql Express

Feb 17, 2007

we're planning to use sql express as our database server in our office. the database will consist of accounting, purchasing, marketing, sales, inventory, production and hrd tables. 80-100 users will use the system simultaneously in adding, editing, deleting, reports.
i need some advice on the following:
1. maximum users that can log on to the database simultaneously?
2. maximum size of the database?

tnx

View 7 Replies View Related

SQL Security :: Users Logged In Server

Jun 12, 2015

We wanted to know list of  users who had logged into the SQL Server from last 10 to 30 days.

View 2 Replies View Related

Added Users To A Logged Shipped Database

Dec 20, 2007

I have 2 sql server 2000 database that participate in log shipping.Server A is the source database, which log ships to a database onServer B. The database on Server B is in a warm stand by/read onlymode. Is there a way that I can add users to the database on ServerB, without having to add the users to the database in server A? I amtrying to use the database on Server B as a reporting only databaseand add more users to have permissions to run reports.Please let me know if anyone has any suggestions. Thank you.

View 2 Replies View Related

Show/hide A Field Based On The Logged In User In Reports

Apr 24, 2007

Hi,



I have some sensitive and non-sensitive info/fields in one of my reports. Is there a way to hide/show the info based on the logged in user? or do I have to create separte reports for each type of info like one for sensitive and another one for non-sensitive info.



Thanks inadvace for your help!



View 3 Replies View Related

Determining The Number Of Active Users Logged Into A SQL Server Database

Apr 20, 2006

How does one Determine the number of Active users logged into a SQL Server Database?

I want to use the info to control concurrent licensing for my Application

View 6 Replies View Related

After The Restore, Db Users Doesn&#39;t Show Up

May 28, 2002

Hi,

After doing a database restore on my development server, It only shows DBO As the db user..When I query SYSUSER all other users are still there..But doesn't show up in enterprise manager...

Anybody came acrosss the same situation ?

Thanks for you help in advance.

View 1 Replies View Related

Script To Show Users And Permissions

Dec 11, 2007

I have looked and looked and looked and can not find an answer to this simple question. I want a way to script out all the permissions for a given user.

I have a user (User1) and he has the following permissions lets say:

Server
- View Server Activity

Database1
- CREATE AGGREGATE
- CREATE DEFAULT
- CREATE FUNCTION
- CREATE PROCEDURE
- CREATE RULE
- CREATE SYNONYM
- CREATE TABLE
- CREATE TYPE
- CREATE VIEW
- SHOWPLAN
- VIEW DEFINITION

Schema1
- SELECT
- INSERT
- DELETE

Schema2
- SELECT
- EXECUTE

Objects
- SELECT ON schema3.table1
- EXECUTE on schema4.storedproc1

I need a something (script, report, voodoo magic spell) that will show me this. It is hard to believe that this is not a built in report with SQL2005. It was hard to do in 2000 but you could do it if you played around with the scripting options enough. I can not find a clear cut way of doing this in 2005 to save my life. Maybe I am just blind, but my fellow DBA's have the same problem.

How can I do this? Please???

Jim Youmans
St Louis

View 6 Replies View Related

SQL Server 2008 :: MDX Query Filtering - Return Sales For Each Customer For Past 6 Weeks

Feb 4, 2015

I'm having problems filtering in my MDX query.

My requirements are to return the sales for each customer for each store, for the past 6 weeks.

The catch is that I only want those customers which have had sales over 10,000 within the last week.

This is my query:

WITH SET [CustomerList] AS
FILTER(
([Store].[Store Name].[Store Name], [Customer].[Customer Name].[Customer Name]),
[Measures].[Sales] >= 10000
AND [Date].[Fiscal Week Name].&[2015-01-26 to 2015-02-01]

[Code] ....

The dates are hard-coded for testing purposes.

View 0 Replies View Related

Query To Linked Indexing Service Returns Nothing When Logged In Through SQL Authentication

Nov 7, 2006

I am struggling to get my linked indexing service to return something when I query it. The thing is, when I use Management Studio and log in through Integrated Windows authentication I have no problems. However, when logging in through a test account that only exists in SQL server I get nothing returned. Some observations:
1. Changing the test account to have sa priveliges changes nothing
2. The test account has db_owner role on source db
3. I have tried to create a login using
sp_addlinkedsrvlogin FTIndexWeb, true, 'SomeLogin' but that didn't work. I also tried to do this manually in Mgt Studio.
4. I did not find any authentication related stuff in the management console of my pc in or near the Indexing Service. I'm not sure if my system imposes any security restraints that are invisible to me.
5. My query is
SELECT * FROM OPENQUERY(DNN4_BF_DMX, 'SELECT Path, Rank FROM SCOPE() WHERE FREETEXT(Contents, ''"Confidential"'')')
6. My setup: Win XP (SP 2), SQL SRV 2005 Express, Mgt Studio Express (SP1), (if relevant) .net frameworks 1.1/2.0.

I need to tell my customers how to get this going reliably and now I feel unsure whether this is at all possible. Anyone abe to shine some light on this?

Thanks,
Peter

View 3 Replies View Related

Query Works In 'test Query' But Refuses To Show Up In The Datagrid On A Web Page - Urgent!

Mar 28, 2007

Hey, i've written a query to search a database dependant on variables chosen by user etc etc. Opened up a new sqldatasource, entered the query shown below and went on to the test query page. Entered some test variables, everything works as it should do. Try to get it to show in a datagrid on a webpage - nothing. No data shows.
 SELECT dbo.DERIVATIVES.DERIVATIVE_ID, count(*) AS Matches
FROM dbo.MAKES INNER JOIN
dbo.MODELS ON dbo.MAKES.MAKE_ID = dbo.MODELS.MAKE_ID INNER JOIN
dbo.DERIVATIVES ON dbo.MODELS.MODEL_ID = dbo.DERIVATIVES.MODEL_ID INNER JOIN
dbo.[VALUES] ON dbo.DERIVATIVES.DERIVATIVE_ID = dbo.[VALUES].DERIVATIVE_ID INNER JOIN
dbo.ATTRIBUTES ON dbo.[VALUES].ATTRIBUTE_ID = dbo.ATTRIBUTES.ATTRIBUTE_ID
WHERE ((ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID1 and (@VAL1 is null or VALUE = @VAL1)) or
(ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID2 and (@VAL2 is null or VALUE = @VAL2)) or
(ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID3 and (@VAL3 is null or VALUE = @VAL3)) or
(ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID4 and (@VAL4 is null or VALUE = @VAL4)) )
GROUP BY dbo.DERIVATIVES.DERIVATIVE_ID
HAVING count(*) >= CASE WHEN @VAL1 IS NOT NULL THEN 1 ELSE 0 END +
CASE WHEN @VAL2 IS NOT NULL THEN 1 ELSE 0 END +
CASE WHEN @VAL3 IS NOT NULL THEN 1 ELSE 0 END +
CASE WHEN @VAL4 IS NOT NULL THEN 1 ELSE 0 END -2
ORDER BY count(*) DESC

 Here is the page source
 
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DevConnectionString1 %>"
SelectCommand="&#9;SELECT dbo.DERIVATIVES.DERIVATIVE_ID, count(*) AS Matches&#13;&#10;&#9;FROM dbo.MAKES INNER JOIN&#13;&#10;&#9;&#9;&#9;&#9; dbo.MODELS ON dbo.MAKES.MAKE_ID = dbo.MODELS.MAKE_ID INNER JOIN&#13;&#10;&#9;&#9;&#9;&#9; dbo.DERIVATIVES ON dbo.MODELS.MODEL_ID = dbo.DERIVATIVES.MODEL_ID INNER JOIN&#13;&#10;&#9;&#9;&#9;&#9; dbo.[VALUES] ON dbo.DERIVATIVES.DERIVATIVE_ID = dbo.[VALUES].DERIVATIVE_ID INNER JOIN&#13;&#10;&#9;&#9;&#9;&#9; dbo.ATTRIBUTES ON dbo.[VALUES].ATTRIBUTE_ID = dbo.ATTRIBUTES.ATTRIBUTE_ID&#13;&#10;&#9;WHERE ((ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID1 and (@VAL1 is null or VALUE = @VAL1)) or&#13;&#10;&#9;&#9; (ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID2 and (@VAL2 is null or VALUE = @VAL2)) or&#13;&#10;&#9;&#9; (ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID3 and (@VAL3 is null or VALUE = @VAL3)) or&#13;&#10;&#9;&#9; (ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID4 and (@VAL4 is null or VALUE = @VAL4)) )&#13;&#10;&#9;GROUP BY dbo.DERIVATIVES.DERIVATIVE_ID&#13;&#10;&#9;HAVING count(*) >= CASE WHEN @VAL1 IS NOT NULL THEN 1 ELSE 0 END +&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; CASE WHEN @VAL2 IS NOT NULL THEN 1 ELSE 0 END +&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; CASE WHEN @VAL3 IS NOT NULL THEN 1 ELSE 0 END +&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; CASE WHEN @VAL4 IS NOT NULL THEN 1 ELSE 0 END -2&#13;&#10;&#9;ORDER BY count(*) DESC&#13;&#10;">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="ATT_ID1" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="TextBox1" Name="VAL1" PropertyName="Text" />
<asp:Parameter Name="ATT_ID2" />
<asp:Parameter Name="VAL2" />
<asp:Parameter Name="ATT_ID3" />
<asp:Parameter Name="VAL3" />
<asp:Parameter Name="ATT_ID4" />
<asp:Parameter Name="VAL4" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DevConnectionString1 %>"
SelectCommand="SELECT * FROM [ATTRIBUTES]"></asp:SqlDataSource>
<br />
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
DataTextField="ATTRIBUTE_NAME" DataValueField="ATTRIBUTE_ID">
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox><br />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="DERIVATIVE_ID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="DERIVATIVE_ID" HeaderText="DERIVATIVE_ID" InsertVisible="False"
ReadOnly="True" SortExpression="DERIVATIVE_ID" />
<asp:BoundField DataField="Matches" HeaderText="Matches" ReadOnly="True" SortExpression="Matches" />
</Columns>
</asp:GridView>
</asp:Content>
 AFAIK I have configured the source to pick up the dropdownlist value and the textbox value (the text box is autopostback).
 Am i not submitting the data correctly? (It worked with a simple query...just not with this one). I have tried a stored procedure which works when testing just not when its live on a webpage.
 Please help!
 
(Visual Web Devleoper 2005 Express and SQL Server Management Studio Express)
 

View 4 Replies View Related

Query To Show ID That Is Not In DB?

Oct 24, 2013

I have a list of OrderIDs and I'd like SQL to show me the ones that do not appear in the DB.

Lets say that my table looks like this:
idorderIdUserItem
122joepotatoes
223SteveApples
324SteveBananas
438DaveCarrots

And the query looks like this:
SELECT orderID FROM sales WHERE orderID IN ('22','51','38')

You'll notice that orderID 51 is not in the table. How do I make it tell me the orderIDs that do not appear?

View 1 Replies View Related

How To Show Boolian Value In Sql Query?

Apr 1, 2008

i have one table completed tabletask_id   task_due_datetime   task_completed_on  1                    03/21/2008        03/25/20082                    03/12/2008        03/10/20083                    03/10/2008        03/18/2008 i want the output:task_id    on time        late 1                  0             1 2                  0             0 3                  0             1  how i get this output in sql query without the use of cursor...  

View 5 Replies View Related

Query To Show Duplicates

Aug 16, 2005

mytable      fld1 int     primkey                  fld2 varchar(20),                  fld3 varchar(20)From the definition of the above table, how do i do i modify my below query to only select the rows with duplicates in fld2.  I know a groupby with a having count will display the duplicates for a given field, but i want my query to see all the fields and rows that are duplicates.     select fld1, fld2, fld3 from mytable                

View 1 Replies View Related

SHOW Query For MSSQL

Sep 18, 2004

What would the MySQL equivalent for "SHOW TABLES" and "SHOW FIELDS" be in MSSQL?

View 8 Replies View Related

Query To Show All Data According To ID

Feb 1, 2015

I have a table i need to show data according to id. distinct id and all name should be comma separated against each id.

DECLARE @TBL TABLE (ID NUMERIC(10), NAME VARCHAR(10))

INSERT INTO @TBL (ID,NAME)
VALUES(1, 'A'), (1,'B') ,(1,'C') ,(2,'E') ,(2,'B') , (3,'F') , (3,'G')

output :

id name

1 a,b,c
2 e,b
3 f,g

View 2 Replies View Related

Show Me Example Of Dynamic SQL Query

Mar 5, 2008

Show me example of dynamic SQL query if possible

thank you

View 5 Replies View Related

Show The Decimal Part In Query

Jun 19, 2008

Hi,In the following query the calculator gives value 3.3  but the query returns 3.0 I need to get the decimal part also. i.e I need to get 3.3 as answer from the query. select cast(66/20 as decimal(6,2)) Need help.Thanks 

View 3 Replies View Related

T-SQL (SS2K8) :: How To Show ED / CESS In Query

Nov 5, 2014

Detail:

create table detail
(
grn_no varchar(55),
po_no varchar(50),
vendor_no numeric(10,2),
Formul_id varchar(50),
Adjust_code varchar(50),
adjus_value float
)

insert into detail values

('Grn/0001/14-15','po/00011/14-15/','5000','ED12','ED12','500')
values ('Grn/0001/14-15','po/00011/14-15/','5000','CST','CST12','50')
values ('Grn/0001/14-15','po/00011/14-15/','5000','CES6','CES6','5')
values ('Grn/0001/14-15','po/00011/14-15/','5000','VAT','VAT','0')
values ('Grn/0001/14-15','po/00011/14-15/','5000','HCES2','HCES2','2.50')

i wanna display ED ,CESS ,HCESS,VAT in separate columns in output How to that?

View 4 Replies View Related

How To Query And Show The Result In A Form

May 12, 2006

I am an beginner in VC#2005,

my question is:

I connect a table and transtorm to WM5.0 (PDAphone),

I don't know how to show the result of my query,

EX:

table1,(two column: name , phoneNo)

private void button1_Click(object sender, EventArgs e)
{
SqlCeConnection cn = null;
try
{
cn = new SqlCeConnection("Data source=\Programs files\sqltest1\sqlPDA.sdf");


SqlCeCommand cmd = new SqlCeCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Table1 where phoneNo='0922123456'";


SqlCeDataAdapter da = new SqlCeDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = cmd;

}
finally
{
if (cn.State != ConnectionState.Closed)
{
cn.Close();
}

}
}

there is nothing happen, please help me.

thanks

View 3 Replies View Related

Transact SQL :: Query To Show Totals

Aug 28, 2015

This is a query that produces a table with garbage data, but (I think) will get the point across of what I need. SQL Server 2008

Create Table SanitationGarbage
(
saleid int
,projectname varchar(200)
,typeofsale varchar(200)

[code]....

Now my select query below does not group the data like I need it to, nor does it show a total row like I need it to.  How does this need to be written so the data is displayed in the proper formatting?

Select
projectname
,Count(saleID) As [Total Sales]
,Count(case when typeofsale = 'Final' then saleID else null end) As [Final Sales]
,Count(case when typeofsale = 'Pending' then saleID else null end) As [Pending Sales]
FROM SanitationGarbage
GROUP BY projectname
order by projectname asc

[code]....

View 4 Replies View Related

SQL.. Studio Query Will Not Show More Than 500 Charcters

Mar 29, 2007

I have a column that is a varchar(1000). When I select that column the whole column doesn't show in the grid. To see the what's in there I right click the cell and "Copy". I then paste the results into notepad.



My problem is that I'm only getting 500 characters. I have several questions:



1. How do I verify that there are more than 500 characters in the column?

2. How do I select all characters in the column?

3. Is there anyway to see them in the Management Studio tool or do I still need to past them into notepad.

View 3 Replies View Related

Show SQL Search Query In Pages

Jul 12, 2007

How to show a SQL search query in pages? for example 10 records in each page, like search engines.
I'm using .NET Framework 2, SQL Server 2000 and Adobe Dreamweaver CS3.
Thanx

View 1 Replies View Related

How Do I Do A Query That Uses All Users?

Jul 5, 2000

Hello,

I am doing a website that incorporates SQL and one of the things is which user to query for. In this part, I would like to put
the variable 'AllUsers' which consists of all the users, do you have any suggestions on how this can be done, here is what I
have without a query for 'AllUsers' in HTML:

<SELECT NAME="targetUserID">
<OPTION VALUE="AllUsers">All Users</OPTION>
<!-- =queryString "select distinct rtrim(userID) from
Track..cUsers order by userID" -->
<!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString tmpuserID -->
<OPTION VALUE= "<!-- $ $tmpuserID -->"
<!-- ({ $tmpuserID == $targetUserID --> SELECTED<!-- (} -->>
<!-- $ $tmpuserID --></OPTION>
<!-- ?}sqlBlock -->
</SELECT>

Here is what I thought would work, but it didn't:

<SELECT NAME="targetUserID">
<!-- =queryString "declare @AllUsers varchar(16) select @AllUsers = userID from Track..cUsers" -->
<!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString AllUsers -->
<OPTION VALUE="AllUsers">All Users</OPTION>
<!-- ?}sqlBlock -->

<!-- =queryString "select distinct rtrim(userID) from
Track..cUsers order by userID" -->
<!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString tmpuserID -->
<OPTION VALUE= "<!-- $ $tmpuserID -->"
<!-- ({ $tmpuserID == $targetUserID --> SELECTED<!-- (} -->>
<!-- $ $tmpuserID --></OPTION>
<!-- ?}sqlBlock -->
</SELECT>



In case you dont like how that looks here is what I thought would work just in SQL:

declare @AllUsers varchar(16)
select @AllUsers = userID
from Track..cUsers

I also tried to do it with my query for the final information, but that didnt work either it went something like this:

select DATEDIFF( hour, startTime, stopTime), cSlice.projectID " +
from Track..cSlice, Track..cProjects
where '" + $targetUserID + "' = 'AllUsers'
and clientID = '" + $targetClientID + "'
and state = 'Stopped'
and typeID = 'Billable'
and cSlice.projectID = cProjects.projectID
and startTime like '" + $targetMonth + "%'
or userID = '" + $targetUserID + "'
and clientID = '" + $targetClientID + "'
and state = 'Stopped'
and typeID = 'Billable'
and cSlice.projectID = cProjects.projectID
and startTime like '" + $targetMonth + "%'
order by cSlice.projectID

Any help would be greatly appreciated, Thank you for your time.
Nathan Czuba

View 1 Replies View Related

Query To Show Life Cycle Revenue?

Jan 2, 2007

I am trying to create a query that will show how much revenue that we have recieved from a customer After the first invoice and I'm having a difficult time creating a query to do it.. I have a customer table  and a sales table joined by custno.
SELECT     Customer.LastName, Sales.InvDate, Sales.AmtChargeFROM         Customer INNER JOIN                      Sales ON Customer.CustNo = Sales.CustNo
 The output I'd like is
CustNo, LastName, FirstInvoiceAmount, LifeCycleAmount
Getting the first inv date seems straight forward
SELECT Customer.CustNo, MIN(Sales.InvDate) AS FirstInv FROM Customer INNER JOIN Sales ON Customer.CustNo = Sales.CustNo GROUP BY Customer.CustNo
However getting the amount of that first inv and then getting the sum of all invoices not including the first invoice has me scratching my head.
 Can anyone point me in the right direction?
 

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved