0

Hi All, I am new to sql and also this is my first post in this THREAD, Inline with this I am going to improve knowledge on sql, so below is my query which i desperately needed and don't know it is possible or not?

I've Two table

Table1: ProblemGroup columns: ProblemCode (19 rows),Problem description (19 rows)

Table2: Complaints Columns: No. of Complaints,Downtime,GroupCode,Vert_id.

Here is what I want

First the table should have

1. the columns : ProblemCode,Problemdescription,Count(No.of Complaints),sum(Downtime)

2. the problemCode and ProblemDescription rows (19) should not vary with the "WHERE CONDITION"

for example:

I've written the below Query

select Count(No. of Complaints), sum(Downtime),P.ProblemCode, P.ProblemDescripton from Complaints c Right Outer Join problemgrp P On C.GROUPCode=P.PROBLEMGRPCode
Group by GROUPCode,PROBLEMGRPCode,DESCRIPTION

Here the result is showing 19 rows

but when writing like this

select Count(No. of Complaints), sum(Downtime),P.ProblemCode, P.ProblemDescripton from Complaints c Right Outer Join problemgrp P On C.GROUPCode=P.PROBLEMGRPCode where Vert_ID='utg' Group by GROUPCode,PROBLEMGRPCode,DESCRIPTION

when writing like this i am getting only 14 rows,

Moral is: Even if I used the filters(like Vert_ID). There should NOT BE change in rows ProblemCode and ProblemDescription (i.e the rows of problemCode and ProblemDescription columns should not vary with the where conditions)

Please help in wirtiing the code

Edited by kiranbvsn: n/a

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by kiranbvsn
0

The WHERE clause is specifically used to reduce the number of results. I'm confused as to why you would want to filter on Vert_ID='utg' and still get all results. I think you want something that must be done in the frontend code, not in SQL.

0

The WHERE clause is specifically used to reduce the number of results. I'm confused as to why you would want to filter on Vert_ID='utg' and still get all results. I think you want something that must be done in the frontend code, not in SQL.

Thank God u understand my problem at first sight "pritaeas"

The problem is i've to bind that data to a repeater (asp:repeater) somethinglike grid
it will even get worse that i've to bind one column to one table and have to do looping in other columns in order to match the results w.r.t first column

can u help in any way

0

Still not quite sure what you want to achieve. Can you give an example of your table/data and the output you require ? (I know what an asp:repeater is...)

0

Still not quite sure what you want to achieve. Can you give an example of your table/data and the output you require ? (I know what an asp:repeater is...)

For ur information please see the attached document pritaeas

Attachments
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.