Click here to Skip to main content
16,021,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
select patientid as Patient,cast (addon as Date) as Date from PatientMaster
  group  by patientid, CAST(addon as date) having CompanyID = 150
Posted
Comments
Aarti Meswania 5-Apr-13 6:32am    
please provide details... some records of i/p & desire o/p
Naseer A Khan 5-Apr-13 6:42am    
actually i am generating MSchart report due to this i am getting data table from my Data base
and i am using Command type "Query" so for this purpose i am using this Query..
i am selecting all patients by date those all patients belong this company which ID is 150.
[no name] 5-Apr-13 6:34am    
"CAST(addon as date)", you are not storing datetime values as something other than datetime are you?
Naseer A Khan 5-Apr-13 6:43am    
sorry sir i am not getting what u are trying to ask me...?
[no name] 5-Apr-13 7:11am    
What is there to "get". Why are you CAST(addon as date)?

select patientid as Patient,cast (addon as Date) as Date from PatientMaster
having CompanyID = 150 group by patientid, CAST(addon as date)
 
Share this answer
 
Comments
Naseer A Khan 5-Apr-13 6:46am    
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'group'.

i tried this query but its prompt me this error
Jayname 5-Apr-13 6:50am    
now try


select patientid as Patient,cast (addon as Date) as Date from PatientMaster
having CompanyID = 150 group by patientid, Date
Naseer A Khan 5-Apr-13 6:55am    
sir still having same error
Jayname 5-Apr-13 7:30am    
select patientid as Patient,cast (addon as Date) as Date from PatientMaster
where CompanyID = 150 order by Patient, Date
now try

select patientid as Patient,cast (addon as Date) as Date from PatientMaster having CompanyID = 150 group by Patient, Date
 
Share this answer
 
Comments
Naseer A Khan 5-Apr-13 6:59am    
sorry sir still having same issue
SQL
select patientid as Patient,cast (addon as Date) as Date from PatientMaster
  order by patientid, CAST(addon as date) having CompanyID = 150
 
Share this answer
 
SQL
select patientid as Patient,cast (addon as Date) as Date from PatientMaster
where CompanyID = 150  order by Patient, Date
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900