SQL Query Problem
-
hi I want to make a query for this data can any one of u help me; DATA:
Person Name value XYZ a 10 XYZ b 5 XYZ a 15 XYZ b 4 XYZ c 1 XYZ a 5 XYZ d 10 XYZ a 10 ... ...
This is the of one group; now for I want this result for this data and so on;
Person Name Total XYZ a 40 XYZ others 20 abc a ## abc others ##
Please write a query for this. Thanks :rose:
Syed Shahid Hussain
-
hi I want to make a query for this data can any one of u help me; DATA:
Person Name value XYZ a 10 XYZ b 5 XYZ a 15 XYZ b 4 XYZ c 1 XYZ a 5 XYZ d 10 XYZ a 10 ... ...
This is the of one group; now for I want this result for this data and so on;
Person Name Total XYZ a 40 XYZ others 20 abc a ## abc others ##
Please write a query for this. Thanks :rose:
Syed Shahid Hussain
-
Syed Shahid Hussain wrote:
Please write a query for this.
Why?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
very stupid, if u dont know then say "i dont know sorry" what do u mean by WHY?
Syed Shahid Hussain
-
very stupid, if u dont know then say "i dont know sorry" what do u mean by WHY?
Syed Shahid Hussain
Syed Shahid Hussain wrote:
if u dont know then say "i dont know sorry"
Instead, I do not reply if I do not know anything about the question.
Syed Shahid Hussain wrote:
what do u mean by WHY?
Is this a quiz website? No. Why should I do your work? If you had tried something and got stuck, then many would be interested to help you.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
-
Syed Shahid Hussain wrote:
if u dont know then say "i dont know sorry"
Instead, I do not reply if I do not know anything about the question.
Syed Shahid Hussain wrote:
what do u mean by WHY?
Is this a quiz website? No. Why should I do your work? If you had tried something and got stuck, then many would be interested to help you.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
d@nish wrote:
Is this a quiz website?
brother it is a forum I think u dont know the meaning of forum, here people help each other without Why? and without any thing. I'd solved my problem but I want some suggestions from others. Now if u know any idea about that then reply otherwise keep quiet thank you very much.
Syed Shahid Hussain
-
d@nish wrote:
Is this a quiz website?
brother it is a forum I think u dont know the meaning of forum, here people help each other without Why? and without any thing. I'd solved my problem but I want some suggestions from others. Now if u know any idea about that then reply otherwise keep quiet thank you very much.
Syed Shahid Hussain
People here help those who help themselves. People here do not prefer spoon feeding in general. Try out something or search google. If you face any problems, then post the query.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
-
People here help those who help themselves. People here do not prefer spoon feeding in general. Try out something or search google. If you face any problems, then post the query.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
I've said that I've solved the problem but I want some perfect solution from the experts, why are u arguing me, and who has given u this right to argue with me.
Syed Shahid Hussain
-
hi I want to make a query for this data can any one of u help me; DATA:
Person Name value XYZ a 10 XYZ b 5 XYZ a 15 XYZ b 4 XYZ c 1 XYZ a 5 XYZ d 10 XYZ a 10 ... ...
This is the of one group; now for I want this result for this data and so on;
Person Name Total XYZ a 40 XYZ others 20 abc a ## abc others ##
Please write a query for this. Thanks :rose:
Syed Shahid Hussain
Syed Shahid Hussain wrote:
Please write a query for this.
Only because you used "Please" am I replying to this. This may be a forum where people help each other, but it is NOT a place where professionals will do your work for you. Most professionals charge for professional work. Instead, we help people who are stuck on a problem. A pre-requisite to getting help is showing that you are able to at least have a stab at doing it yourself, and therefore when you hit a specific problem, people here are more than happy to help. But just saying "Please do x for me" will get you either the reply you've gotton above, or a quotation. I can do this work for you at £50 + VAT per hour and I imagine with implementation and testing there is 3 hours work there.
-
I've said that I've solved the problem but I want some perfect solution from the experts, why are u arguing me, and who has given u this right to argue with me.
Syed Shahid Hussain
Syed Shahid Hussain wrote:
I've solved the problem
Then I suggest you show your solution and ask if anyone sees ways to improve on it. That way typically leads to a more interesting thread. :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
-
Syed Shahid Hussain wrote:
I've solved the problem
Then I suggest you show your solution and ask if anyone sees ways to improve on it. That way typically leads to a more interesting thread. :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
leave it dear, now first time i'm irritating with this site, code project. Every time when i post a question i received a perfect solution or at least pleasant comments not like these stupid phrases. One want 3 hr to solve it and i'd given only 2 hr to solve it and make related crystal report with complete formatting. now just stop posting replies on this question.
Syed Shahid Hussain
-
Syed Shahid Hussain wrote:
Please write a query for this.
Only because you used "Please" am I replying to this. This may be a forum where people help each other, but it is NOT a place where professionals will do your work for you. Most professionals charge for professional work. Instead, we help people who are stuck on a problem. A pre-requisite to getting help is showing that you are able to at least have a stab at doing it yourself, and therefore when you hit a specific problem, people here are more than happy to help. But just saying "Please do x for me" will get you either the reply you've gotton above, or a quotation. I can do this work for you at £50 + VAT per hour and I imagine with implementation and testing there is 3 hours work there.
try this, select person , name, sum(tot_values) from ( select person, case when name = 'a' then 'a' else 'others' end as name , sum(tot_values) as tot_values from test_tabb group by person,name ) X group by person,name order by person desc, name
-
try this, select person , name, sum(tot_values) from ( select person, case when name = 'a' then 'a' else 'others' end as name , sum(tot_values) as tot_values from test_tabb group by person,name ) X group by person,name order by person desc, name
-
hi I want to make a query for this data can any one of u help me; DATA:
Person Name value XYZ a 10 XYZ b 5 XYZ a 15 XYZ b 4 XYZ c 1 XYZ a 5 XYZ d 10 XYZ a 10 ... ...
This is the of one group; now for I want this result for this data and so on;
Person Name Total XYZ a 40 XYZ others 20 abc a ## abc others ##
Please write a query for this. Thanks :rose:
Syed Shahid Hussain
Try this declare @tbl table(person varchar(50),name varchar(50),value int) insert into @tbl select 'xyz','a',10 union all select 'xyz','b',5 union all select 'xyz','a',15 union all select 'xyz','b',4 union all select 'xyz','c',1 union all select 'xyz','a',5 union all select 'xyz','d',10 union all select 'xyz','a',10 union all select 'abc','a',0 union all select 'abc','b',0 union all select 'abc','c',0 union all select 'abc','d',0
;with cte as
(
select person,name,sum(value) as total from @tbl group by person,name
)select person,'others' as name , SUM(total) as total from cte where name not in('a')
group by person
union all
select person,'a' as name , SUM(total) as total from cte where name in('a')
group by person
order by person desc:)
Niladri Biswas