mysql - Building an table using procedures -


i'm trying create procedure returns table information of database, lists number of hotel how many clients used each type of credit cards on hotel

keeping in mind there more 50 hotels , 3 types of credit cards, want procedure run through data , list in table

delimiter //     drop procedure if exists `testing` // create procedure `testing`(out param1 varchar(40))  begin  declare id_cnpjestabelecimento varchar(40); declare id_redecartão varchar(255);  select (cnpjestabelecimento)  fpcsmovatlantica201308tst04; set id_cnpjestabelecimento := cnpjestabelecimento;  select (id_redecartão)  fpcsmovatlantica201308tst04; set id_redecartão := id_redecartão;  select count(*) fpcsmovatlantica201308tst04; redecartão 'id_redecartão%'; , cnpjestabelecimento 'id_cnpjestabelecimento%';  end // delimiter ; 

an example of select

 select count(*)  fpcsmovatlantica201308tst04  redecartão 'cielo%'  , cnpjestabelecimento '02223966000466%' 

the cnpjestabelecimento got several values, more 100+, it's inviable make selects

i don't have use procedures make it, final result

select cnpjestabelecimento, redecartão, count(*) fpcsmovatlantica201308tst04 redecartão 'cielo%' group cnpjestabelecimento,redecartão 'cielo%' order cnpjestabelecimento asc; 

i'm assuming have 1 table, looks kind of this:

|hotelid|cardtype|etc... 

i'd go with:

select hotelid, cardtype, count(*) mytable group hotelid, cardtype 

i tested here following sql:

select country, city, count(*) customers group country, city order country; 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -