Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

Need help in SQL Query Expand / Collapse
Author
Message
Posted Wednesday, October 9, 2013 3:40 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, December 8, 2013 10:34 PM
Points: 33, Visits: 151
Hi,

I have a group called Leaders group. Users belonging to this Leaders group should be able to see only people information belonging to Leaders group. The following people belong to Leaders group[a,,c,d,e,f]. I need to display this for a SSRS report. Can anyone help me with the query.

Post #1502992
Posted Wednesday, October 9, 2013 3:52 AM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, December 18, 2013 5:03 AM
Points: 1,454, Visits: 135
Please provide the Sample data and the result how you expect?
Post #1502994
Posted Wednesday, October 9, 2013 4:32 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, December 8, 2013 10:34 PM
Points: 33, Visits: 151
Here is the one

User_Profile
User_Id User_FullName Email User_Group

Group_Lookup
LOB_GRP LOB_CD LOB_TYPE_CD

Impacted_LOB
Event_ID LOB_CD

First user log-ins which is queried in User_Profile table. Then I try to relate User_Group and LOB_GRP.
Then I have a group called CCSG Group in LOB_GRP column in Group_Lookup table. So now this CCSG Group has its respective LOB_CD in same table. Now I need to compare LOB_CD column of Group_Lookup and Impacted_LOB and display the result for that particular group.
Post #1503009
Posted Wednesday, October 9, 2013 6:35 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, December 8, 2013 10:34 PM
Points: 33, Visits: 151
Hi Parul,

Can you help me with this query.
Post #1503063
Posted Wednesday, October 9, 2013 7:05 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:45 AM
Points: 7,102, Visits: 6,933
Best guess

SELECT up.User_Id, up.User_FullName, up.Email, up.User_Group ,i.Event_ID 
FROM User_Profile a
JOIN User_Profile up ON up.User_Group = a.User_Group
JOIN Group_Lookup g ON g.LOB_GRP = up.User_Group
JOIN Impacted_LOB i ON i.LOB_CD = g.LOB_CD

Really need test data and expect results to form a better solution.



Far away is close at hand in the images of elsewhere.

Anon.

Post #1503077
Posted Wednesday, October 9, 2013 7:33 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, December 8, 2013 10:34 PM
Points: 33, Visits: 151
Hi David,

Here is my exact one

Here is the one
USER_PRFL
User_Id User_FullName Email User_Group

BSP_LOB_Grp_Lookup
BSP_LOB_GRP BSP_LOB_CD BSP_LOB_GRP_TYPE_CD

IMPACTED_LOB
Event_ID BSP_LOB_CD

Scenario1:
First user log-ins which is queried in USER_PRFL table. Then I try to relate User_Group and BSP_LOB_GRP.
Now I have a value called CCSG Group in BSP_LOB_GRP column in BSP_LOB_Grp_Lookup table. So now this CCSG Group has its respective BSP_LOB_CD in same table. Now I need to compare BSP LOB_CD column of BSP_LOB_Grp_Lookup and IMPACTED_LOB and display the result for that particular group.
On top of this the following values (Life, MLCT, GenAm, NEF, Annuity, Auto and Home, Annuity and Investments) present in BSP_LOB_GRP should belong to CCSG Group of the sane column.

Post #1503100
Posted Wednesday, October 9, 2013 7:41 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 10:51 AM
Points: 13,311, Visits: 12,173
As David suggested earlier, in order to help we will need a few things:

1. Sample DDL in the form of CREATE TABLE statements
2. Sample data in the form of INSERT INTO statements
3. Expected results based on the sample data

Please take a few minutes and read the first article in my signature for best practices when posting questions.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1503106
Posted Wednesday, October 9, 2013 7:48 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, December 8, 2013 10:34 PM
Points: 33, Visits: 151
Hi Sean,

I really appreciate it. I am new to this forum and new to SQL too and will do the one you tod me going forward. As of now this is all I have right now. Is there any way you can help me on this.

Moreover this is my original data that I have furnished here.


  Post Attachments 
Tables.docx (20 views, 214.42 KB)
Post #1503111
Posted Wednesday, October 9, 2013 7:57 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, December 8, 2013 10:34 PM
Points: 33, Visits: 151
Hi,

I am attaching my sql table structure for a best solution.
Post #1503115
Posted Wednesday, October 9, 2013 7:57 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 10:51 AM
Points: 13,311, Visits: 12,173
vigneshlagoons (10/9/2013)
Hi Sean,

I really appreciate it. I am new to this forum and new to SQL too and will do the one you tod me going forward. As of now this is all I have right now. Is there any way you can help me on this.

Moreover this is my original data that I have furnished here.


We are all willing and able to help but you have to help us by providing details to work with. I understand you are a bit overwhelmed since you are new to sql. That is ok, we can work with that.

There is no data here. All you provided was a few table names and the column names for those tables. We don't know what datatypes you are using and we have no idea what the data might look like. We aren't even really sure what you are trying to do. Once you provide the details for your question we can help you formulate an answer.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1503116
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse