gpt4 book ai didi

javascript - 如何订购预购餐 table

转载 作者:行者123 更新时间:2023-11-28 06:34:36 25 4
gpt4 key购买 nike

当我用这个“union select”查询数据库时:

select stampata_sn,numero_conto,dest_stampa,portata,categoria,prog_inser,nodo,desc_art,prezzo_un,quantita from comanda where contiene_variante='1' and ntav_comanda='1' and posizione='CONTO' and stato_record='ATTIVO'   and numero_conto = '1' 
union all
select stampata_sn,numero_conto,dest_stampa,portata,categoria,prog_inser,nodo,desc_art,prezzo_un,sum(quantita) as quantita from comanda where (contiene_variante !='1' or contiene_variante is null) and length(nodo)=3 and ntav_comanda='1' and posizione='CONTO' and stato_record='ATTIVO' and numero_conto = '1' group by desc_art
union all
select stampata_sn,numero_conto,dest_stampa,portata,categoria,prog_inser,nodo,desc_art,prezzo_un,quantita from comanda where length(nodo)=7 and ntav_comanda='1' and posizione='CONTO' and stato_record='ATTIVO' and numero_conto = '1' order by nodo asc;

我按顺序提取这些数据:

PROGRESSIVO NODO    PRODOTTO            QUANTITA
0 000 SAN PELLEGRINO 1
1 001 MINERALWASSER 0.2 l 1
2 002 MINERALWASSER 0.4 l 1
3 003 COCA COLA 0.2 l 3
4 004 COCA COLA 0.4 l 1
5 005 COLA LIGHT 0.2 l 5
6 006 COLA LIGHT 0.4 l 3
7 007 APFELSAFT 0.4 l 1
12 007 012 +SCHWARZWALD 1
13 007 013 -ERDBEEREN 1
8 008 APFELSAFT 0.2 l 2
10 010 SPRITE 0.4 l 1
11 011 SPRITE 0.2 l 1

顺序是正确的,因为变体链接到产品,但我想按字母顺序查看它们,如下所示:

PROGRESSIVO NODO        PRODOTTO            QUANTITA
11 008 APFELSAFT 0.2 I 2
7 007 APFELSAFT 0.4 I 1
8 007 012 + SCHWARZWALD 1
10 007 013 - ERDBEEREN 1
3 003 COCA COCA 0.2 I 3
4 004 COCA COLA 0.4 I 1
5 005 COLA LIGHT 0.2 l 5
6 006 COLA LIGHT 0.4 l 3
1 001 MINERALWASSER 0.2 l 1
2 002 MINERALWASSER 0.4 l 1
0 000 SAN PELLEGRINO 1
12 011 SPRITE 0.2 l 1
13 010 SPRITE 0.4 l 1

我该怎么办?

最佳答案

您可以尝试将 SQL 包装在外部 SQL 中,如下所示

select A.stampata_sn
,A.numero_conto
,A.dest_stampa
,A.portata
,A.categoria
,A.prog_inser
,A.nodo
,A.desc_art
,A.prezzo_un
,A.quantita
FROM
(
select stampata_sn
,numero_conto
,dest_stampa
,portata
,categoria
,prog_inser
,nodo
,desc_art
,prezzo_un
,quantita
from comanda
where contiene_variante='1'
and ntav_comanda='1'
and posizione='CONTO'
and stato_record='ATTIVO'
and numero_conto = '1'
union all
select stampata_sn
,numero_conto
,dest_stampa
,portata
,categoria
,prog_inser
,nodo
,desc_art
,prezzo_un
,sum(quantita) as quantita
from comanda
where (contiene_variante !='1' or contiene_variante is null)
and length(nodo)=3
and ntav_comanda='1'
and posizione='CONTO'
and stato_record='ATTIVO'
and numero_conto = '1' group by desc_art
union all
select stampata_sn
,numero_conto
,dest_stampa
,portata
,categoria
,prog_inser
,nodo
,desc_art
,prezzo_un
,quantita
from comanda
where length(nodo)=7
and ntav_comanda='1'
and posizione='CONTO'
and stato_record='ATTIVO'
and numero_conto = '1'
) A
order by <Field to order by here> asc;

我不确定您想要使用哪个字段来排序,因为列标题 PRODOTTO 没有显示在列列表中。您可以使用任何列名称来排序,例如 -“A.portata”。

此外,按 desc_art 分组的第二个 SQL 似乎不符合 ANSI 标准,通常当您按所选列列表中的所有非聚合列进行分组时,应该是分组依据的一部分。您可能需要查看此内容并检查是否获得了正确的结果。

关于javascript - 如何订购预购餐 table ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34398616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com