Transact SQL :: Find A Count On Group Of Member IDs

Aug 20, 2015

I am trying to find a count on group of our memberid`s who were active within a year since 2010 till today for particular memberships in my table I have memberid int effectivedate datetime termdate datetime Membershiptype varchar(10) ='GOLD','Silver' and 'Platinum'. I haven't used sql in a long time..

View 6 Replies


ADVERTISEMENT

A New Member Could Not Be Added To A Local Group Because The Member Has The Wrong Account Type

Mar 23, 2007

Hi all,

I installed SQL 2005 SP2 + ReportServices Add-in for Sharepoint (WSS 3.0). All it's OK until I try to grant database access in the Sharepoint Central Admin site.

I setup the Reporting Services Integration (Manage integration settings). I use the default SQL instance, I put the USERNAME and the PASSWORD of my ADMIN account in the ENTER CREDENTIALS windows.. When I click the "OK" button, I receive always the error ...

"A new member could not be added to a local group because the member has the wrong account type"

I tried a lot of things... without success.

Is there someone who can help me....

PS: There is no error in the LOG



Thanks

View 18 Replies View Related

A New Member Could Not Be Added To A Local Group Because The Member Has The Wrong Account Type

Mar 23, 2007

Hi all,

I installed SQL 2005 SP2 + ReportServices Add-in for Sharepoint (WSS 3.0). All it's OK until I try to grant database access in the Sharepoint Central Admin site.

I setup the Reporting Services Integration (Manage integration settings). I use the default SQL instance, I put the USERNAME and the PASSWORD of my ADMIN account in the ENTER CREDENTIALS windows.. When I click the "OK" button, I receive always the error ...

"A new member could not be added to a local group because the member has the wrong account type"

I tried a lot of things... without success.

Is there someone who can help me....

PS: There is no error in the LOG



Thanks

View 4 Replies View Related

Transact SQL :: Display 0 With COUNT And GROUP BY

Aug 25, 2015

How can I display 0 when using COUNT and GROUP BY?I'm using SELECT CASE in my query. I was trying to use COALESCE but no result, COUNT result = 1. (there should be 0).

COALESCE((COUNT(DISTINCT (CAST((CASE
WHEN CurrStat = @Stat AND LogDate = @LogDate THEN Enumber ELSE 0 END) AS int)))), 0) AS InTrack,

View 5 Replies View Related

Transact SQL :: How To Select Columns That Are Not In GROUP BY And Get COUNT

Jul 3, 2015

I am using SQL 2012.  I have a GROUP BY and I want to select two other fields from my table at the same time: One column that is a string (account_code) and one that I need to perform a count on (customer_number).  I know the code COUNT(DISTINCT customer_number) works for getting that.   I need to select both of those fields on top of what I have.  I have the following:

DECLARE @Providers TABLE (ID INT IDENTITY(1,1),
Provider_Name VARCHAR(20),
Uniq_Id VARCHAR(10),
Total_Spent MONEY,
Total_Earned MONEY)
INSERT INTO @Providers (Provider_Name, Uniq_Id,Total_Spent,
Total_Earned)

[Code] .....

View 21 Replies View Related

Transact SQL :: Group By Count Once For Duplicate Column Values?

Oct 1, 2015

My data is like below: 
 
ClassId ClassName   StudentId   Subject     SubjectId 
1         ESL       12         English      20 
1         ESL       13         Science     30 
1         ESL       12         Social       40 
1         ESL       12         Maths        50 
 
Required output: parameters are Subject column values 

ClassId ClassName   TotalStudents   SubjectIds  
 
1        ESL                     1              20, 40, 50 
1        ESL                     1              30 
 
When one student takes multiple subjects then count student only once, so in the above data 12 is one student id takes multiple subjects so counted only once. TotalStudents value is 1
 
I did write below query: 
 
Declare @subjectids string 
set @subjectids = '20,30,40,50' 

-- will split @subjectids  and store in temp table    

select classname, classid, Count(Distinct StudentId) 
from mytable 
where SubjectsIds in @subjectIds 
group by ClassId, ClassName, SubjectId, 
 
but it gives me below output:   

ClassId ClassName   TotalStudents   SubjectIds 
 
1        ESL        1              20 
1        ESL        1              30 
1        ESL        1              40 
1        ESL        1              50 

View 9 Replies View Related

Calculated Member Count Problem

Jul 17, 2005

I've been having difficulties with the following mdx query:

WITH
MEMBER [Measures].[Group] AS
'Mid(MemberToStr([PhaseTask].CurrentMember),30,1)'

MEMBER [Measures].[LawFirmDesc] AS 'MemberToStr([Lawfirm].CurrentMember)'

SET [ClaimCloseDate_Set] AS '{[ClaimCloseDate].[All ClaimCloseDate].[2004] }'

MEMBER [ClaimCloseDate].[All ClaimCloseDate].[SelectedClaimCloseDates] AS
'Aggregate([ClaimCloseDate_Set])'

SET [Jurisdiction_Set] AS
'{
[Jurisdiction].[All Jurisdiction].[State]
}'

MEMBER [Jurisdiction].[All Jurisdiction].[SelectedJurisdiction] AS
'Aggregate([Jurisdiction_Set])'

MEMBER [Measures].[ClaimCount] AS
'Count(NonEmptyCrossJoin(Descendants(
[Case].CurrentMember,,LEAVES),
[ClaimCloseDate_Set],
[Jurisdiction_Set],
{[PhaseTask].[All PhaseTask]},
{[Lawfirm].CurrentMember}, 1))'

SELECT {
[Measures].[LawFirmDesc],
[Measures].[Group],
[Measures].[ClaimCount],
[Measures].[Legal Fees Approved],
[Measures].[Expenses Approved],
[Measures].[Hours Approved]} ON COLUMNS,
CrossJoin (
{
[PhaseTask].[All PhaseTask].[L100 Assessment].Children,
[PhaseTask].[All PhaseTask].[L200 Pre-Trial].Children,
[PhaseTask].[All PhaseTask].[L300 Discovery].Children,
[PhaseTask].[All PhaseTask].[L400 Trial].Children,
[PhaseTask].[All PhaseTask].[L500 Appeal].Children,
[PhaseTask].[All PhaseTask].[E100 Expenses].Children,
[PhaseTask].[All PhaseTask].[Indemnity],
[PhaseTask].[All PhaseTask].[Prior Legal Fees]
},
{[Lawfirm].[All Lawfirm]
}
) ON ROWS
FROM Datamart_Vis_Ins165_Claim

WHERE
(
[Case].[All Case].[C],
[FeeAgreement].[All FeeAgreement].[Hourly + Expenses],
[ClaimCloseDate].[All ClaimCloseDate].[2004],
[Jurisdiction].[All Jurisdiction].[State]
)



The problem is [Claim Count]. I want the claim count on each row to be the highest claim count from selected rows and placed on each row. The count is way under-reported. However, If I use a simple count statement or distinct count then only the last 2 rows have the count value I am looking for. It doens't seem to be affected by the where clause or the aggregated sets so it is over-reporting on the claim count. Anyone have any thoughts on how to solve this problem?

Basically, I'm cross joining law firms with tasks that show expenses and fees submitted by law firms for billing. I need to calulate averages by dividing the dollar amounts by a claim count. The twist is that the claim count I am looking for only occurs on the indemnity and prior legal fees rows because I know that every claim/case has an indemnity and prior-legal fee transaction in the fact table. The others types of transactions don't. So I have to assume the claim count is max claim count calculated on one of the rows and that number needs to be applied to the rest. Also, the count has to be adjusted by the slicers in the where clause (when I used a simple count statement it wasn't adjusting as I changed the values in the where clause) The slicers in the where clause change the date, or the jurisdiction as well as other dimensions. Hope this information has helped. Any suggestions would be greatly appreciated.

View 2 Replies View Related

Find Out If Current User Is Member Of A Role

Aug 5, 2004

I need a stored procedure to find out if the current user is a member of a certain role. I want to pass the role name and return a bit to tell whether he is a member or not. I have this code to list the groups the current user is a member of but I don't know how to search or do a "SELECT FROM" on the results.DECLARE @usr varchar(32) SET @usr = USER EXEC sp_helpuser @usr But if the current user is a member of more than one role it returns multiple rows. So if I could do something like: DECLARE @grpName varchar(32) SELECT * FROM (EXEC sp_helpuser @usr) WHERE GroupName=@grpNameIF rowcount > 0 THENRETURN 1ELSERETURN 0END IF I know that doesn't work so how can I do this?

View 6 Replies View Related

Hide [+]/[-] Toggle Sign When Group Doesnot Have Any Member

May 23, 2007

Hi,

I need help to hide [+]/[-] sign when a group doesnot have any item in it. Currently, I have a table with a group header where I put the companyName and in the detail section I put the users for that company. I want that, if a company doesnot have any users then there should not be any [+]/[-] sign next to it. Please help!!

Thanks,

-Rohit

View 1 Replies View Related

How To Determine If The Logged On User Is A Member Of An Active Directory Security Group?

Aug 7, 2007



We are using Windows authenication within our system, and I was wondering how it would be possible to determine if the user conected to the SQL SERVER instance was a member of a particular active directory security group?

Thanks.

View 3 Replies View Related

SQL 2012 :: Fast Way To Do Group By Count On Items Within Group?

May 1, 2014

select top 15 count(*) as cnt, state from table
group by state
order by cnt desc

[code[...

Can the above three queries be combined into one and still be fast, if so how?What i am trying to go is an item count, by group, similar to ones Inbox in Outlook.

View 9 Replies View Related

Transact SQL :: Overlapping Dates For Same Member Query

Oct 18, 2015

IF OBJECT_ID('tempdb..#OverLappingDates') IS NOT NULL
    DROP TABLE #OverLappingDates
    CREATE TABLE #OverLappingDates
(
    MemberID           Varchar (50),
    ClaimID               Varchar(50),
    StartDate             DateTime,
    EndDate               DateTime
)

[Code] ....

I need to select only records where dates are over lapping for the same memberid...For this scenario i need an output First 2 records  (MemberID 1 has 2 claiims overlapping dates).                

View 2 Replies View Related

Adding A Group By Clause And Getting A Count Of A Group

Feb 6, 2008

HiI am new to SQL and am having a problem. I need to fix my query to do the following...2) get a total of the number of rows returned.
DECLARE @StartDate varchar(12)DECLARE @EndDate   varchar(12)DECLARE @Region    varchar(20)
SET @StartDate = '01/01/2002'SET @EndDate   = '12/31/2008'SET @Region    = 'Central'
SELECTA.createdon,A.casetypecodename,A.subjectidname,A.title,A.accountid,A.customerid,A.customeridname,B.new_Region,B.new_RegionName
FROM  dbo.FilteredIncident AINNER JOIN dbo.FilteredAccount B ON A.customerid = B.accountid
WHERE (A.createdon >=@StartDate  AND A.createdon <= @EndDate)AND   (B.new_RegionName = @Region)AND   (A.casetypecode = 2) 
 

View 1 Replies View Related

How?: Group By Date And Count Rows In Group

Jan 29, 2007

I'm new to MSSQL 2005 and want to get a summary of a log table. I want to count all the rows for each date based on a DATETIME field called 'post_date' that holds the date and time of each record's creation.

this is the best I can come up with:

Code:


SELECT
DISTINCT(LEFT(post_date,11)) AS post_date, COUNT(DISTINCT(LEFT(post_date,11))) AS total_posts
FROM log_directory_contacts
GROUP BY post_date



The results show each date but the count column ('total_posts') returns '1' for every row even when I know their are more than 1 record on that date.

What am I doing wrong? Thanks!

View 9 Replies View Related

Transact SQL :: Server Trigger To Monitor Member Of Sysadmin Activities

Jul 22, 2015

I have to make server trigger to monitor the actitites if sysadmin members. i need to get the login name,hostname and query which they are running.

View 3 Replies View Related

Master Data Services :: How To Add A Reference To Another Entity Member When Creating A Member

Oct 23, 2014

I need to create a member that one of its Attributes (maybe my term is wrong) is a reference to another entity member named group 
the code 

createRequest.Members.MemberType = MemberType.Leaf;
createRequest.Members.Members = new System.Collections.ObjectModel.Collection<Member> { };
Member aNewMember = new Member();
aNewMember.MemberId = new MemberIdentifier() { Name = uag.groupName, MemberType = MemberType.Leaf };

[code]....

 "The attribute data type is not valid".Is it wrong to add the reference as attribute? How can I embed the reference in the new member? 

View 4 Replies View Related

SQL 2012 :: Delete Rows If Member Does Not Exists In The Member Table

Sep 24, 2015

I have a table where I need to delete rows if the member does not exists in the member table. Will the following syntax work ?

Delete T
FROM Event_Temp_Lead_Screen T
left join member M on ( M.MemberID = T.MemberID )
where
T.Gender is NULL

View 9 Replies View Related

Problem In SQL Developing As Restricted User (member Of User Group)

Nov 19, 2005

Greetings,VWD EE and other Tools do not have problems working O.K. on my machine, when I am logged-on as restricted(limited) user, both environment and local web server are functioning, and it was MS effort to do it right.BUT the Problem is, when I try to connect to database->new DB connection(either through vwd or management studio etc). I get an Error - which should be written to event log (according to msg) but it isn't - that I can't connect. I am sure that it is because NO SQL SERVER2005EXPRESS instance is running, which I think is the only prerequisite to have it work (I do not need sqlbrowser service I am doint local development).SQL2005express service is configured on MANUAL start. I can start it as administrator through SQL config manager, but it is not convienient and what I want. I need to start it ONLY as a developer user, I do not want it to be running all-the-time for everyuser using computer. It was congigured as Network Service logon, I tried Local Service logon, and I even tried configuring it to logon as -my developer user- account, e.g. with limited user name and his password.In every case I can't start the service as member of users group and this developer. Then I added limited user to SQL2005EXPRESS group. Still NO help, won't start either.My question is, If I want to start developing ADO2.NET application and I need to have running SQL2005Express instance as a develper, how can I start it? I think I do not have some rights to masterDB or something. Do it allways need to be running when computer starts? Isn't there any other way, to start it JUST when I think I start developing?I know of user-mode of accessing SQL2005express DBs, but it also assumes that SQL2005Express service is already running, what I am trying to prevent. I do not want to have it running for everyone who uses computer, just for someone who neeeds it.Any help explaining me the right way HOW TO SETUP WORKING ENVIRONMENT when developing as limited user welcome, I read the the documentations and haven't found the answers.THANK YOU !

View 1 Replies View Related

Group By And Count

Dec 21, 2007

I want to know how to merge the following data.  I am using 4 queries below.  I was hoping to do it with 1 query.   Table1Dist     Fund     VAE    AOVAW   AOMD      CourtMD     JudgeCAC   AOCAC   CourtVAE   JudgeVAE   JudgeI want to join the following 3 queries:DcountAll                                                                                                   DcountAOSelect Dist, Count(Dist)as Count from Table1  GROUP BY Table1.Dist           Select Dist, Count(Dist) as Count from Table1 Where Dist='AO' GROUP BY Table1.DistDcountCourtSelect Dist, Count(Dist) as Count from Table1 Where Dist='Court' GROUP BY Table1.DistSELECT DCountAll.Dist, DCountAll.Count, DcountAO.Count AS AO, DcountCourt.CountFROM DcountCourt RIGHT JOIN (DcountAO RIGHT JOIN DCountAll ON DcountAO.Dist = DCountAll.Dist) ON DcountCourt.Dist = DCountAll.Dist;

View 2 Replies View Related

Help ... COUNT + GROUP BY

May 30, 2008

hi everyone, I have a table: Help
A               B    C05/01/2008 100 1 05/01/2008 100 205/01/2008 100 205/01/2008 200 1 05/01/2008 200 2 
SELECT A, COUNT(DISTINCT C) FROM help GROUP BY A 
Result:1> 05/01/2008 2I need:1> 05/01/2008 4Thanks !!!

View 4 Replies View Related

How To Count GROUP BY

Nov 3, 1998

TO all SQL Gurus,

The following statement returns let say 4 records -

SELECT title, price FROM table GROUP BY title

what is the correct syntax for the statement to return the count of 4 ?

if I put ->

SELECT count (*) FROM table GROUP BY title

it'll return 1.

Thanks,


Frank

View 4 Replies View Related

Help On Count And Group

May 23, 2008

Hi everybody I have this sql code

SELECT i.infid, i.infname, i.infcalled, p.pubinfid, p.pubpub, p.publang, p.pubcount, p.pubid, n.cdpldesc
FROM info AS i INNER JOIN
pubssubscribe AS p ON i.infid = p.pubinfid INNER JOIN
newpubs AS n ON p.pubid = n.pubid
WHERE (i.infcond IS NULL)AND (p.pubid BETWEEN 30 AND 33) AND (p.pubcount > 1) AND (NOT (p.publang = '.'))

there are many records where infid appears more than once because people could subscribe in different in different publicatons.
ex.

infid pubid
1 30
1 32
1 33
2 30

etc... I want to count the infid appearing once and group it with infid

thanks

View 7 Replies View Related

Sum Of COUNT In Group By

Mar 25, 2004

SELECT emp_id,COUNT(*)
FROM emp
GROUP BY empId

THe above query returns the values

empid COUNT
1 4
2 4
3 5

BUT i want sum of the count (13) in the same query. How to achieve this.

Thanks.

View 4 Replies View Related

Help ... COUNT &#043; GROUP BY

May 29, 2008

hi everyone,

I have a table: Help

A B C
05/01/2008 100 1
05/01/2008 100 2
05/01/2008 100 2
05/02/2008 200 1
05/02/2008 200 2

SELECT a, COUNT(c) FROM Help GROUP BY a

Result:

1> 05/01/2008 3
2> 05/02/2008 2

But I need grouping columns B and C so that the result was

1> 05/01/2008 2
2> 05/02/2008 2

Is it possible? How can I do?
Thanks.

View 5 Replies View Related

Count Of Group By?

Jul 29, 2013

I want to join two tables and count the rows on the second table as something is grouped by the first. To be more clear. I have vendors and open tracking numbers for orders they have shipped. I want to list the vendor information and to group by the vendor. However I also want to count how many open orders that vendor has - which is on a different table. I have this so far:

SELECT `companyName`
, `emailAddress`
, `ccAddress`
, `dailyMessages`
, (SELECT count(*) FROM `tracking` WHERE `pkgStatus`!='4') AS 'openTracking'
FROM `vendor`
LEFT OUTER JOIN `tracking`
ON `vendor`.`id` = `tracking`.`vendorID`
WHERE (SELECT count(*) FROM `tracking` WHERE `pkgStatus`!='4') > 0
GROUP BY `vendor`.`id`

The problem is that this code results in this table. Where openTracking is always equal to the total count, not distinct to that vendor's ID

View 3 Replies View Related

SQL COUNT, SUM AND GROUP BY

Apr 5, 2006

Hello
I'm putting together a football database and want to show how many games a player played in a season.

SELECT COUNT (PlayerFixture.FixtureID) FROM PlayerFixture WHERE PlayerFixture.PlayerID = '::PlayerID::' GROUP BY Season

However if a player doesn't play any games in a particular season the COUNT function ignores it and just returns values in seasons he has played. Is there any way i can get the COUNT function to return a "0" or "-" if a player didn't play any games that season?

Cheers

View 10 Replies View Related

Count GROUP

Mar 13, 2007

hi,
this sounds simple, but ive to idea how ..
1. how to count all records we found when there's group by?
SELECT ItemID, CustomLotNo, Ownership
FROM tblItemDetail
GROUP BY ItemID, CustomLotNo, Ownership
ORDER BY ItemID

2. how to print rows number for each record? like the Expr1 column
Expr1 ItemID CustomLotNo Ownership
1 A A01 INT1
2 C GPB01 JAB2MY

~~~Focus on problem, not solution~~~

View 12 Replies View Related

Sub Group Count

Apr 24, 2008

I am doing employee shift report. I am showing totals for the shift, day and store. Store is the main group, day is the sub group under store group and shift is the sub group under the day group. I want to calculate number of shift group records (Number of shifts) and use it in the store level group calculation.

How to do it?

Thanks,
Muniappan Kandasamy

View 1 Replies View Related

Group By Count * &&>1?

May 23, 2007

Can this be used to prevent the repetition of records displayed in a page?




Code Snippet

SELECT T_ProgramGuests, GuestName
FROM T_ProgramGuests
GROUP BY ProgramID, GuestName
HAVING (COUNT(*) > 1)

I'm trying to prevent names being repeated. I only want the name to show once followed by the next name and so on. But only once.

View 1 Replies View Related

Group By Having Count(*)

Jan 4, 2008

I would like to select data from a database using 'Select * " based on a value in a row (same column)being unique.
By that I mean that that data must not repeat again. Idealy I would like to set the number my self so rather then unique I could say

select the rows from the database only if the uniquevalue does not repeat more then x number of times.
eg
Value A
Value B
Value C
Value B
Value B
Value C

So if I wanted to set the uniquness to 1 then only row with Value A would be collected.
If I set the uniquenss to =<2 then I would get data from rows with value A and C so
3 rows returned.

I have this so far

SELECT *
FROM SingleS.mdb
GROUP BY Uniquevalue
HAVING count(*) = 1

View 7 Replies View Related

Help ... COUNT + GROUP BY

May 30, 2008

Hi everyone,

I have a table: Help

A B C
05/01/2008 100 1
05/01/2008 100 2
05/01/2008 100 2
05/01/2008 200 1
05/01/2008 200 2

SELECT A, COUNT(DISTINCT C) FROM help GROUP BY A

Result:

1> 05/01/2008 2

I need:

1> 05/01/2008 4

Thanks !!!

View 12 Replies View Related

COUNT &&amp; GROUP BY

Oct 25, 2007

Probably has been solved a million times, but here it is anyway:

Say I have a table with follwoing rows:

Site Appointment Maintenance Date
NY 13 10-25-2007
CA 14 10-29-2007
NY 18 10-25-2007
NJ NULL 10-26-2007

I need to perform a simple count showing the total (Maintenance Dates) for the next 2 days. Additionally, if a site is listed, but it doesn't have any (Maintenance Dates) for the next 2 days, it must be part of the report with the total as zero.

I can do
SELECT Site, COUNT(*)
FROM dbo.MyTable
GROUP BY Site
-- for brevity, assume GETDATE() is set to 12:00 AM, today
WHERE [Maintenance Date] >= GETDATE() AND [Maintenance Date] < DATEADD(dd, 2, GETDATE())

but this only lists NJ and NY, because they both have counts over the next days. How do I get CA in the list?

Thanks.

View 6 Replies View Related

Group By And Count Of Each Group

Oct 23, 2007

Hi,
I use group by myItem, that displays rows for each value of myItem.
I want at the end of each group for each specific myItem, I want an extra row to tell me the count of the rows for that group.

How do i do that please. Here s what I need, for example for this set of rows:


myItem colum2 colum3
711056 22662 Finances / -2291 -2479916
711056 22663 Finances / -2380 -2576255
711056 43428 Cda) -323 -349635
711056 43428 . -B-(Cda) -44 -47628
711057 44348 . -B-(Cda) -355 -384273
711057 47033 . -B-(Cda) -1278 -1383384

I need 2 extra rows, one at the end of the items 711056 telling me there are 4 rows for the item 711056 and one row at the very end telling me there are: 2 rows for the item: 711057

Thanks a lot.

View 6 Replies View Related







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