the further discuss has moved to:http://bytes.com/topic/mysql/answers...-a#post3716261
thanks for Rabbit's help.
User Profile
Collapse
Profile Sidebar
Collapse
bbaaking
Last Activity: Apr 27 '12, 02:10 AM
Joined: Apr 17 '12
Location:
-
bbaaking replied to complicated SQL:how to using a query to compute rank of order(Outstanding of Class 1)in MySQLhi Rabbit,
I googled "having" usage, and I tried this statement:
select TCID,ID v1, endTime from service group by TCID having v1>20
It is right. So there must be something wrong with "case when".
But how to fix it. I have no idea. Can you give me a further hint?Leave a comment:
-
bbaaking replied to complicated SQL:how to using a query to compute rank of order(Outstanding of Class 1)in MySQLsorry, I had made a big mistaken for I missed your code. I must be a fool. please forgive me.
I have changed the convert function, and met a error message: "Unknown column 'T2.EndMonth' in 'having clause'", It is just like what u have said.
I will study your statement carefully, for It is too complicated to me to understand, then I will make more fix.
thank you.Leave a comment:
-
bbaaking replied to complicated SQL:how to using a query to compute rank of order(Outstanding of Class 1)in MySQLhi Rabbit
As much as I know, mysql does not support these keywords:with,o ver,row_number, partition by.
I think It must be a hard job to make this conversion, and out of my ablility, Maybe out of the most people's ability.
Anyway, thanks for your suggestion.
Actually, I'm studying ESPROC as It is my only practical solution. I will take It as my final solution in the project at this friday if I can't make...Leave a comment:
-
bbaaking replied to complicated SQL:how to using a query to compute rank of order(Outstanding of Class 1)in MySQLhi Luuk,
I need a MySQL solution.
I have got a MSSQL solution from a friend, but I(and this friend) can't onvert it to MySQL, for they are too different, and It is out of my ability.
check the MSSQL solution:
Code:WITH MonthCount AS (SELECT DATEDIFF(mm, MIN(EndTime), MAX(EndTime)) + 1 AS MonthCountField FROM service), rank_of_person as( select
Leave a comment:
-
bbaaking replied to complicated SQL:how to using a query to compute rank of order(Outstanding of Class 1)in MySQLhi Rabbit,
thanks for your reply.
but your suggestion is out of my ability, I can't do it correctly. as you know, there seems no "with","over"," partition by" in mysql syntax. I can't write it out. so I need a help here.Leave a comment:
-
bbaaking replied to How to filtrate duplicate data about technical support and compute rank of orderin MySQLafter filtering duplicate date, the TCID and cnt(Personal Total Satisfied Services this Month) and rank should be:Code:month cnt TCID rank 1 4 Andrew 1 1 1 Daniel 5 1 2 Dyla 3 1 3 Jacob 2 1 2 Tyler 3 2 4 Andrew 1 2 1 Daniel 5 2 4 Dyla 1 2 4 Jacob 1 2 2 Tyler
Leave a comment:
-
bbaaking replied to How to filtrate duplicate data about technical support and compute rank of orderin MySQLhi Rabbit,
Thank you for your reply. Maybe I didn't give the clear information, I'm sorry for that.
I have run that SQL using EMS SQL Manger just now and few days befor, It can run correctly without any syntax wrong. I have taken a screenshot as below:
Let me explain:
1. this statement was not written out by myself. It was from another net friends.
2. Actually, I do not understand this...Leave a comment:
-
bbaaking replied to How to filtrate duplicate data about technical support and compute rank of orderin MySQLFinally,I find a solution(http://stackoverflow.com/questions/1...75434#10275434).
that is using esProc to solve this problem. esProc is the only solution I found. Yes, It can return a resultSet object and invoked by report Tool ( I'm using Jasper). But I still need a SQL solution. so, please told me If there are any SQL solution. Thanks for your reply....Leave a comment:
-
bbaaking replied to complicated SQL:how to using a query to compute rank of order(Outstanding of Class 1)in MySQLhi luuk,
thanks for your work though you didn't solve this problem. You are a nice guy.
I must use SQL because I should return a dataset/resultSet to reporting tools , Jasper only identify SQL ( JAVA bean may does too, but It seems too complicated).
I find a solution(http://stackoverflow.com/questions/1...75434#10275434).
that...Leave a comment:
-
bbaaking replied to complicated SQL:how to using a query to compute rank of order(Outstanding of Class 1)in MySQLThank you, luuk.
I noticed that your statement is almost right,but there must be some mistaken, because I want rank but not rownumber by order.
as an example: 1,1,10 rank is 1,1,3. otherwise, I cann't chose the people with the same data.
after filtering duplicate date, the TCID and cnt(Personal Total Satisfied Services this Month) and rank should be:
Code:month cnt TCID rank 1 4 Andrew 1 1 1 Daniel 5 1
Leave a comment:
-
bbaaking started a topic complicated SQL:how to using a query to compute rank of order(Outstanding of Class 1)in MySQLcomplicated SQL:how to using a query to compute rank of order(Outstanding of Class 1)
Hi,
I have be in trouble for 2 weeks, hope some nice people can help me.
Background:Ther e are some technical service data (ServiceID, TCID, EndTime, and QoS) submitted by client in a whole year about technical support, and there are a unique primary key (ID by name) because there are some duplicates. I must use one single query statement(not insert/delete/update, and not stored procedure) to process a computation,... -
bbaaking replied to How to filtrate duplicate data about technical support and compute rank of orderin MySQLhi, I have got the anwser of aim1:
Code:SELECT DISTINCT serviceid,tcid,endtime,qos FROM (SELECT * FROM service ORDER BY serviceid, qos, id) AS base GROUP BY serviceid
Leave a comment:
-
bbaaking replied to How to filtrate duplicate data about technical support and compute rank of orderin MySQLhi, Rabbit
a nice people give me a SQLServer solution, but I still need a mysql solution. statement of sqlserver is:Code:select * from ( select *, row_number() over (partition by [ServiceID] order by Qos) RN from [Service] ) T where RN = 1 order by [ServiceID]
Leave a comment:
-
bbaaking replied to How to filtrate duplicate data about technical support and compute rank of orderin MySQLhi,Rabbit
thank you for your answer. but I only need query statement because customer did not allow us to write database. actually, I had suggested to add a field "ID", It is a big concession to the client. We are BPO and working on the business online database(so I cant add a stored procedure to the database).
I think the correct answer is below (but I cant write it with SQL):
Code:2000 2 Jacob 2011/1/1
Leave a comment:
-
bbaaking started a topic How to filtrate duplicate data about technical support and compute rank of orderin MySQLHow to filtrate duplicate data about technical support and compute rank of order
I’ve got a big problem with this complicated SQL. Could anyone give me a hand?
My first aim(not the final goal) is:fliter the duplicate data with query statment( select not delete) , that is, the various entries of EndTime and Qos for a same ServiceID due to the repeated feedback. The rule is to only keep the records with the lowest Qos for a same ServiceID. If there are several records having the lowest Qos, then only keep whatever...Last edited by bbaaking; Apr 18 '12, 08:03 AM. Reason: aim 1 had solved, I make it clear, and find help about aim2 ,3,and 4(my final goal)
No activity results to display
Show More
Leave a comment: