Click here to Skip to main content
15,891,567 members
Home / Discussions / Database
   

Database

 
GeneralRe: Procedure with Multiple Update Problem Pin
Joe15-Jan-08 23:43
Joe15-Jan-08 23:43 
GeneralRe: Procedure with Multiple Update Problem Pin
Vimalsoft(Pty) Ltd16-Jan-08 0:28
professionalVimalsoft(Pty) Ltd16-Jan-08 0:28 
GeneralHelp me with SQL Query Pin
Vimalsoft(Pty) Ltd15-Jan-08 21:59
professionalVimalsoft(Pty) Ltd15-Jan-08 21:59 
GeneralCommand object use to add data to a database Pin
CodingLover15-Jan-08 18:28
CodingLover15-Jan-08 18:28 
GeneralRe: Command object use to add data to a database Pin
CodingLover15-Jan-08 19:12
CodingLover15-Jan-08 19:12 
QuestionWhat is 'IsMSShipped' ?? Pin
imsathy15-Jan-08 16:51
imsathy15-Jan-08 16:51 
GeneralRe: What is 'IsMSShipped' ?? Pin
Kishore.P15-Jan-08 18:02
Kishore.P15-Jan-08 18:02 
GeneralCreating a View Pin
AAGTHosting15-Jan-08 7:37
AAGTHosting15-Jan-08 7:37 
I need to create a view but I need to know why my select statement is not working.

Here is the select statement. When I take out count(l.stud_id) and count (l.less_id) the query executes. In this view I need to show how many students exist for each teach_id and how many lessons exist for each teach_id.

create view view_reports AS<br />
Select l.teach_id, tp.tp_pymt, t.teach_fname, t.teach_lname, tp.tp_pymt_mon, tp.tp_pymt_yr,<br />
count(l.stud_id), count(l.less_id) <br />
From tbl_teach_pymt tp, tbl_teachers t, tbl_lessons l<br />
Where l.less_start_date < cast(getdate() as datetime)<br />
AND l.less_end_date > cast(getdate() as datetime)<br />
Group BY l.teach_id;


Here are the database tables that I am creating the view from.

create table tbl_teachers (<br />
teach_id int NOT NULL IDENTITY(51000,1),<br />
rent_id int,<br />
teach_fname text,<br />
teach_lname text,<br />
teach_add text,<br />
teach_unit_num text,<br />
teach_city text,<br />
teach_state text,<br />
teach_zip int,<br />
teach_instruments text,<br />
teach_email text,<br />
teach_phone int,<br />
teach_cell int,<br />
start_date datetime,<br />
primary key(teach_id),<br />
foreign key(rent_id) references tbl_rent(rent_id));<br />
<br />
create table tbl_teach_pymt (<br />
tp_id int NOT NULL IDENTITY(10000,1),<br />
teach_id int,<br />
tp_pymt money,<br />
tp_pymt_date datetime,<br />
tp_pymt_mon as(datepart(m, tp_pymt_date)) persisted,<br />
tp_pymt_yr as(datepart(yy, tp_pymt_date)) persisted,<br />
tp_date datetime,<br />
tp_credit text,<br />
primary key(tp_id),<br />
foreign key(teach_id) references tbl_teachers(teach_id));<br />
<br />
create table tbl_lessons (<br />
less_id int NOT NULL IDENTITY(30000,1),<br />
teach_id int,<br />
stud_id int,<br />
less_start_date datetime,<br />
less_end_date datetime,<br />
less_time as(datepart(hh:mm, ss_datetime)) persisted,<br />
less_day int,<br />
less_instrument text,<br />
primary key(less_id),<br />
foreign key(teach_id) references tbl_teachers(teach_id),<br />
foreign key(stud_id) references tbl_students(stud_id));

GeneralRe: Creating a View Pin
Colin Angus Mackay15-Jan-08 9:58
Colin Angus Mackay15-Jan-08 9:58 
GeneralRe: Creating a View Pin
AAGTHosting15-Jan-08 20:16
AAGTHosting15-Jan-08 20:16 
QuestionPerformance question Pin
Kosta Cherry15-Jan-08 7:35
Kosta Cherry15-Jan-08 7:35 
GeneralRe: Performance question Pin
Colin Angus Mackay15-Jan-08 9:49
Colin Angus Mackay15-Jan-08 9:49 
GeneralRe: Performance question Pin
Kosta Cherry15-Jan-08 13:48
Kosta Cherry15-Jan-08 13:48 
GeneralRe: Performance question Pin
Colin Angus Mackay15-Jan-08 14:19
Colin Angus Mackay15-Jan-08 14:19 
GeneralRe: Performance question Pin
Paul Conrad19-Jan-08 7:07
professionalPaul Conrad19-Jan-08 7:07 
Generalcreating table adapter queries using code Pin
Cory Kimble15-Jan-08 7:10
Cory Kimble15-Jan-08 7:10 
GeneralRe: creating table adapter queries using code Pin
Kishore.P15-Jan-08 18:22
Kishore.P15-Jan-08 18:22 
GeneralRe: creating table adapter queries using code Pin
Cory Kimble16-Jan-08 4:00
Cory Kimble16-Jan-08 4:00 
GeneralPad Left Access SQL Pin
Kschuler15-Jan-08 3:37
Kschuler15-Jan-08 3:37 
GeneralRe: Pad Left Access SQL Pin
andyharman15-Jan-08 4:00
professionalandyharman15-Jan-08 4:00 
GeneralRe: Pad Left Access SQL Pin
Kschuler15-Jan-08 4:12
Kschuler15-Jan-08 4:12 
GeneralRe: Pad Left Access SQL Pin
GuyThiebaut15-Jan-08 10:33
professionalGuyThiebaut15-Jan-08 10:33 
QuestionHow to get the PK value within an update trigger Pin
ScottM115-Jan-08 0:45
ScottM115-Jan-08 0:45 
GeneralRe: How to get the PK value within an update trigger Pin
Pete O'Hanlon15-Jan-08 1:36
mvePete O'Hanlon15-Jan-08 1:36 
GeneralRe: How to get the PK value within an update trigger Pin
ScottM117-Jan-08 1:22
ScottM117-Jan-08 1:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.