SQL Basics

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesSQL Basics

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old February 11th, 2016, 02:58 AM
JR83 JR83 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Feb 2016
Posts: 2 JR83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 55 sec
Reputation Power: 0
Problem with numeric values

HI All

I have an issue that I cant seem to resolve. I have a two views joined together that call out only certain values. However the one value is a numeric field and when I input a value into this numeric field it duplicates onto all entries. Also the numeric field is to only return results if the adverse_event field is a yes otherwise it should just stay empty:

Here is my relating code:

View 1:

select A.NumericCol,
B.Client_Id,
B.TextCol AS NOTE,
B.DateCol AS dATE


from AMGR_User_Fields A
INNER JOIN AMGR_Notes B ON A.Client_Id = B.Client_Id


WHERE A.Type_Id = 145 --AND A.Code_Id = 0

GROUP BY B.Client_Id, A.NumericCol, B.TextCol, B.DateCol



View 2:

SELECT D.First_Name + ' ' + D.Name as Contact,
D.Phone_1 AS MAIN,
D.Phone_3 AS CELL,
A.DateCol as Date_of_contact,
A.TextCol as NOTE,
MAX(case when C.Type_Id = 146 then C.Description end) As Adverse_Event,
MAX(case when C.Type_Id = 138 then C.Description end) As Identified_by_med_info,
b.Client_Id AS CLIENT_ID,
b.Contact_Number as Contact_Number,
a.Type as type


from AMGR_Notes A
inner join AMGR_User_Fields B on b.Client_Id = a.Client_Id
inner join AMGR_User_Field_Defs C on b.Code_Id = c.Code_Id AND C.Type_Id = B.Type_Id
inner join AMGR_CSCases E on A.client_id = e.Case_Id
inner join AMGR_Client D on d.Client_Id = E.Client_Id


WHERE C.Type_Id in (138,146)
AND A.Entity_Type = 5
and b.Contact_Number in ('0','1')
--and A.datecol between @StartDate and @EndDate
And a.Type = 9
--and A.CONTACT_DATE between @StartDate and @EndDate
GROUP BY B.Client_Id, A.TextCol, A.DateCol, d.First_Name, d.Name, D.Phone_1, D.Phone_3, b.Contact_Number, a.Type


View 2 works great however view one is the issue.
here is my joining statement:

sELECT B.CONTACT AS CONTACT,
B.MAIN AS PHONE,
B.CELL AS CELL,
B.DATE_OF_CONTACT AS DATE,
B.NOTE AS REFERENCE,
B.ADVERSE_EVENT AS AE,
B.IDENTIFIED_BY_MED_INFO AS IBMF,
A.NUMERICCOL AS ACTION_TAKEN,
B.type as Type


FROM CSV A
INNER JOIN CSV1 B ON A.client_id = b.client_id

GROUP BY A.NUMERICCOL, B.ADVERSE_EVENT, B.IDENTIFIED_BY_MED_INFO, B.CONTACT, B.NOTE, B.DATE_OF_CONTACT, B.MAIN, B.CELL, b.type

What happens is the following, only the entries that have a value in the numericcol are returned however I don't want that, I want all entries regardless if they have a value or not to be returned.

Please help!!

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesSQL Basics > Problem with numeric values


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap