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

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.

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

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...)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.